From 75cf048876a30b3ad9cc53d6dcfd2bec47275173 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Thu, 4 Apr 2024 15:47:04 +0800 Subject: [PATCH] fix type errors of MkAvatar --- packages/client/src/components/global/MkAvatar.vue | 12 ++++++------ packages/firefish-js/src/entities.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/global/MkAvatar.vue b/packages/client/src/components/global/MkAvatar.vue index 54ce1693a7..0a5d466f09 100644 --- a/packages/client/src/components/global/MkAvatar.vue +++ b/packages/client/src/components/global/MkAvatar.vue @@ -98,7 +98,7 @@ const props = withDefaults( ); const emit = defineEmits<{ - (ev: "click", v: MouseEvent): void; + click: [v: MouseEvent]; }>(); const url = computed(() => @@ -123,18 +123,18 @@ watch( }, ); -const gallery = ref(null); +const gallery = ref(null); onMounted(() => { const lightbox = new PhotoSwipeLightbox({ dataSource: [ { - src: url, + src: url.value, w: 300, h: 300, }, ], - gallery: gallery.value, + gallery: gallery.value || undefined, children: ".avatar", thumbSelector: ".avatar", loop: false, @@ -174,7 +174,7 @@ onMounted(() => { history.pushState(null, "", location.href); addEventListener("popstate", close); // This is a workaround. Not sure why, but when clicking to open, it doesn't move focus to the photoswipe. Preventing using esc to close. However when using keyboard to open it already focuses the lightbox fine. - lightbox.pswp.element.focus(); + lightbox.pswp?.element?.focus(); }); lightbox.on("close", () => { removeEventListener("popstate", close); @@ -186,7 +186,7 @@ onMounted(() => { function close() { removeEventListener("popstate", close); history.forward(); - lightbox.pswp.close(); + lightbox.pswp?.close(); } }); diff --git a/packages/firefish-js/src/entities.ts b/packages/firefish-js/src/entities.ts index c5f09fb2d6..a628f038e1 100644 --- a/packages/firefish-js/src/entities.ts +++ b/packages/firefish-js/src/entities.ts @@ -6,7 +6,7 @@ export type DateString = string; type TODO = Record; // NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように -export type User = UserLite | UserDetailed; +export type User = UserLite & Partial; export type UserLite = { id: ID;