mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 23:44:11 +01:00
added reactivity tu current user
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import RDialog from "@/components/common/RDialog.vue";
|
||||
import userApi from "@/services/api/user";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import storeUsers from "@/stores/users";
|
||||
import type { Events, UserItem } from "@/types/emitter";
|
||||
import { defaultAvatarPath } from "@/utils";
|
||||
@@ -12,6 +13,7 @@ import { useDisplay } from "vuetify";
|
||||
const user = ref<UserItem | null>(null);
|
||||
const { lgAndUp } = useDisplay();
|
||||
const show = ref(false);
|
||||
const auth = storeAuth();
|
||||
const usersStore = storeUsers();
|
||||
const imagePreviewUrl = ref<string | undefined>("");
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
@@ -52,6 +54,9 @@ function editUser() {
|
||||
timeout: 5000,
|
||||
});
|
||||
usersStore.update(data);
|
||||
if (data.id == auth.user?.id) {
|
||||
auth.setUser(data);
|
||||
}
|
||||
})
|
||||
.catch(({ response, message }) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
|
||||
@@ -6,6 +6,7 @@ import storeUsers, { type User } from "@/stores/users";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { defaultAvatarPath, formatTimestamp } from "@/utils";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, onMounted, ref } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
@@ -14,6 +15,7 @@ const userSearch = ref("");
|
||||
const { xs } = useDisplay();
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const usersStore = storeUsers();
|
||||
const { all } = storeToRefs(usersStore);
|
||||
const auth = storeAuth();
|
||||
const HEADERS = [
|
||||
{
|
||||
@@ -106,7 +108,7 @@ onMounted(() => {
|
||||
:items-per-page-options="PER_PAGE_OPTIONS"
|
||||
:search="userSearch"
|
||||
:headers="HEADERS"
|
||||
:items="usersStore.all"
|
||||
:items="all"
|
||||
:sort-by="[{ key: 'username', order: 'asc' }]"
|
||||
fixed-header
|
||||
fixed-footer
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
import storeAuth from "@/stores/auth";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import { defaultAvatarPath } from "@/utils";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
// Props
|
||||
const navigationStore = storeNavigation();
|
||||
const auth = storeAuth();
|
||||
const { user } = storeToRefs(auth);
|
||||
</script>
|
||||
<template>
|
||||
<v-hover v-slot="{ isHovering, props: hoverProps }">
|
||||
@@ -18,8 +20,8 @@ const auth = storeAuth();
|
||||
>
|
||||
<v-img
|
||||
:src="
|
||||
auth.user?.avatar_path
|
||||
? `/assets/romm/assets/${auth.user?.avatar_path}?ts=${auth.user?.updated_at}`
|
||||
user?.avatar_path
|
||||
? `/assets/romm/assets/${user?.avatar_path}?ts=${user?.updated_at}`
|
||||
: defaultAvatarPath
|
||||
"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user