From 9de20b4c54d192a20f9135388de9fa13121ed322 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Sun, 16 Oct 2022 19:36:50 +0200 Subject: [PATCH] feat: use getter and helper in other components as well --- src/components/home/TheNavigation.vue | 12 +++--------- src/components/tasks/partials/editAssignees.vue | 10 ++++++---- src/modelTypes/IUser.ts | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/components/home/TheNavigation.vue b/src/components/home/TheNavigation.vue index 5569a1ccad..77d0b6e0eb 100644 --- a/src/components/home/TheNavigation.vue +++ b/src/components/home/TheNavigation.vue @@ -44,8 +44,8 @@ variant="secondary" :shadow="false" > - - {{ userInfo.name !== '' ? userInfo.name : userInfo.username }} + + {{ authStore.userDisplayName }} @@ -80,7 +80,7 @@ {{ $t('about.title') }} {{ $t('user.auth.logout') }} @@ -117,8 +117,6 @@ const canWriteCurrentList = computed(() => baseStore.currentList.maxRight > Righ const menuActive = computed(() => baseStore.menuActive) const authStore = useAuthStore() -const userInfo = computed(() => authStore.info) -const userAvatar = computed(() => authStore.avatarUrl) const configStore = useConfigStore() const imprintUrl = computed(() => configStore.legal.imprintUrl) @@ -136,10 +134,6 @@ onMounted(async () => { listTitle.value.style.setProperty('--nav-username-width', `${usernameWidth}px`) }) -function logout() { - authStore.logout() -} - function openQuickActions() { baseStore.setQuickActionsActive(true) } diff --git a/src/components/tasks/partials/editAssignees.vue b/src/components/tasks/partials/editAssignees.vue index 29315269fc..78a1a3577f 100644 --- a/src/components/tasks/partials/editAssignees.vue +++ b/src/components/tasks/partials/editAssignees.vue @@ -41,6 +41,7 @@ import {success} from '@/message' import {useTaskStore} from '@/stores/tasks' import type {IUser} from '@/modelTypes/IUser' +import { getDisplayName } from '@/models/user' const props = defineProps({ taskId: { @@ -65,7 +66,7 @@ const taskStore = useTaskStore() const {t} = useI18n({useScope: 'global'}) const listUserService = shallowReactive(new ListUserService()) -const foundUsers = ref([]) +const foundUsers = ref([]) const assignees = ref([]) let isAdding = false @@ -114,13 +115,14 @@ async function findUser(query: string) { return } - const response = await listUserService.getAll({listId: props.listId}, {s: query}) + const response = await listUserService.getAll({listId: props.listId}, {s: query}) as IUser[] // Filter the results to not include users who are already assigned - foundUsers.value = response.filter(({id}) => !includesById(assignees.value, id)) + foundUsers.value = response + .filter(({id}) => !includesById(assignees.value, id)) .map(u => { // Users may not have a display name set, so we fall back on the username in that case - u.name = u.name === '' ? u.username : u.name + u.name = getDisplayName(u) return u }) } diff --git a/src/modelTypes/IUser.ts b/src/modelTypes/IUser.ts index 01b64a927f..45d46298ce 100644 --- a/src/modelTypes/IUser.ts +++ b/src/modelTypes/IUser.ts @@ -7,7 +7,7 @@ export const AUTH_TYPES = { 'LINK_SHARE': 2, } as const -type AuthType = typeof AUTH_TYPES[keyof typeof AUTH_TYPES] +export type AuthType = typeof AUTH_TYPES[keyof typeof AUTH_TYPES] export interface IUser extends IAbstract { id: number