From 74b6d9c5f287d91a31d8784a77eb4483f92edd66 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 15 Oct 2023 15:09:43 -0700 Subject: [PATCH] refactor: add typing to emits Signed-off-by: Varun Patil --- src/components/ClusterGrid.vue | 5 +++ src/components/ScrollerManager.vue | 4 ++ src/components/SelectionManager.vue | 4 ++ src/components/Settings.vue | 4 ++ src/components/Timeline.vue | 41 +++++++++++-------- src/components/admin/AdminMixin.ts | 4 ++ src/components/frame/Cluster.vue | 4 ++ src/components/frame/Photo.vue | 8 ++++ src/components/frame/RowHead.vue | 4 ++ src/components/frame/XImg.vue | 5 +++ src/components/modal/AddToAlbumModal.vue | 3 +- src/components/modal/AlbumCreateModal.vue | 3 +- src/components/modal/AlbumDeleteModal.vue | 3 +- src/components/modal/AlbumForm.vue | 5 +++ src/components/modal/AlbumPicker.vue | 7 +++- src/components/modal/AlbumShareModal.vue | 3 +- src/components/modal/AlbumsList.vue | 4 ++ src/components/modal/EditExif.vue | 4 ++ src/components/modal/FaceDeleteModal.vue | 3 +- src/components/modal/FaceEditModal.vue | 3 +- src/components/modal/FaceList.vue | 8 ++-- src/components/modal/FaceMergeModal.vue | 3 +- src/components/modal/FaceMoveModal.vue | 3 +- src/components/modal/Modal.vue | 4 +- .../modal/MultiPathSelectionModal.vue | 4 ++ src/components/modal/NodeShareModal.vue | 5 ++- .../top-matter/DynamicTopMatter.vue | 4 ++ src/components/top-matter/OnThisDay.vue | 4 ++ src/components/viewer/ImageEditor.vue | 4 ++ 29 files changed, 126 insertions(+), 34 deletions(-) diff --git a/src/components/ClusterGrid.vue b/src/components/ClusterGrid.vue index e9ff971c..66edf888 100644 --- a/src/components/ClusterGrid.vue +++ b/src/components/ClusterGrid.vue @@ -61,6 +61,11 @@ export default defineComponent({ }, }, + emits: { + click: (item: ICluster) => true, + plus: () => true, + }, + data: () => ({ recyclerWidth: 300, }), diff --git a/src/components/ScrollerManager.vue b/src/components/ScrollerManager.vue index 6162986e..a15133cb 100644 --- a/src/components/ScrollerManager.vue +++ b/src/components/ScrollerManager.vue @@ -90,6 +90,10 @@ export default defineComponent({ }, }, + emits: { + interactend: () => true, + }, + data: () => ({ /** Last known height at adjustment */ lastAdjustHeight: 0, diff --git a/src/components/SelectionManager.vue b/src/components/SelectionManager.vue index 0375e596..87e3de4a 100644 --- a/src/components/SelectionManager.vue +++ b/src/components/SelectionManager.vue @@ -165,6 +165,10 @@ export default defineComponent({ }, }, + emits: { + updateLoading: (delta: number) => true, + }, + data: () => ({ show: false, size: 0, diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 3ac58806..bf078a22 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -187,6 +187,10 @@ export default defineComponent({ mixins: [UserConfig], + emits: { + 'update:open': (open: boolean) => true, + }, + data: () => ({ localFolders: [] as nativex.LocalFolderConfig[], }), diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 37213356..4e8d1d64 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -44,24 +44,25 @@ @click="selectionManager().selectHead(item)" /> - + @@ -135,6 +136,10 @@ export default defineComponent({ mixins: [UserConfig], + emits: { + daysLoaded: (stats: { count: number }) => true, + }, + data: () => ({ /** Loading days response */ loading: 0, diff --git a/src/components/admin/AdminMixin.ts b/src/components/admin/AdminMixin.ts index f4c03f62..b3b69a38 100644 --- a/src/components/admin/AdminMixin.ts +++ b/src/components/admin/AdminMixin.ts @@ -33,6 +33,10 @@ export default defineComponent({ }, }, + emits: { + update: (key: keyof ISystemConfig, value: any) => true, + }, + methods: { update(key: keyof ISystemConfig, value: any = null) { this.$emit('update', key, value); diff --git a/src/components/frame/Cluster.vue b/src/components/frame/Cluster.vue index 20fbcae9..d2b4ef78 100644 --- a/src/components/frame/Cluster.vue +++ b/src/components/frame/Cluster.vue @@ -62,6 +62,10 @@ export default defineComponent({ }, }, + emits: { + click: (item: ICluster) => true, + }, + computed: { previewUrl() { if (this.error) return errorsvg; diff --git a/src/components/frame/Photo.vue b/src/components/frame/Photo.vue index e0875971..26d30ebc 100644 --- a/src/components/frame/Photo.vue +++ b/src/components/frame/Photo.vue @@ -96,6 +96,14 @@ export default defineComponent({ }, }, + emits: { + select: (e: PointerEvent) => true, + pointerdown: (e: PointerEvent) => true, + touchstart: (e: TouchEvent) => true, + touchmove: (e: TouchEvent) => true, + touchend: (e: TouchEvent) => true, + }, + data: () => ({ touchTimer: 0, faceSrc: null as string | null, diff --git a/src/components/frame/RowHead.vue b/src/components/frame/RowHead.vue index c9f0b70f..6da3ebcd 100644 --- a/src/components/frame/RowHead.vue +++ b/src/components/frame/RowHead.vue @@ -36,6 +36,10 @@ export default defineComponent({ }, }, + emits: { + click: (item: IHeadRow) => true, + }, + computed: { name() { // Check cache diff --git a/src/components/frame/XImg.vue b/src/components/frame/XImg.vue index a8d78d4c..530118c7 100644 --- a/src/components/frame/XImg.vue +++ b/src/components/frame/XImg.vue @@ -29,6 +29,11 @@ export default defineComponent({ }, }, + emits: { + load: (src: string) => true, + error: (error: Error) => true, + }, + data: () => { return { dataSrc: BLANK_IMG, diff --git a/src/components/modal/AddToAlbumModal.vue b/src/components/modal/AddToAlbumModal.vue index 7a5ff8c3..2d635c7d 100644 --- a/src/components/modal/AddToAlbumModal.vue +++ b/src/components/modal/AddToAlbumModal.vue @@ -37,6 +37,8 @@ export default defineComponent({ AlbumPicker, }, + emits: [], + data: () => ({ show: false, photos: [] as IPhoto[], @@ -66,7 +68,6 @@ export default defineComponent({ this.show = false; this.photos = []; this.opsTotal = 0; - this.$emit('close'); }, routeIsAlbum(album: IAlbum) { diff --git a/src/components/modal/AlbumCreateModal.vue b/src/components/modal/AlbumCreateModal.vue index cd548c3d..b73da2b4 100644 --- a/src/components/modal/AlbumCreateModal.vue +++ b/src/components/modal/AlbumCreateModal.vue @@ -31,6 +31,8 @@ export default defineComponent({ AlbumForm, }, + emits: [], + data: () => ({ show: false, album: null as any, @@ -59,7 +61,6 @@ export default defineComponent({ close() { this.show = false; - this.$emit('close'); }, done({ album }: { album: { basename: string; filename: string } }) { diff --git a/src/components/modal/AlbumDeleteModal.vue b/src/components/modal/AlbumDeleteModal.vue index e5bf0aa0..9bb6436c 100644 --- a/src/components/modal/AlbumDeleteModal.vue +++ b/src/components/modal/AlbumDeleteModal.vue @@ -40,6 +40,8 @@ export default defineComponent({ Modal, }, + emits: [], + data: () => ({ show: false, user: '', @@ -65,7 +67,6 @@ export default defineComponent({ methods: { close() { this.show = false; - this.$emit('close'); }, open() { diff --git a/src/components/modal/AlbumForm.vue b/src/components/modal/AlbumForm.vue index cd978c33..383f5bc1 100644 --- a/src/components/modal/AlbumForm.vue +++ b/src/components/modal/AlbumForm.vue @@ -124,6 +124,11 @@ export default defineComponent({ }, }, + emits: { + done: (album: any) => true, + back: () => true, + }, + data: () => ({ collaborators: [], showCollaboratorView: false, diff --git a/src/components/modal/AlbumPicker.vue b/src/components/modal/AlbumPicker.vue index 971d6960..41b15ef8 100644 --- a/src/components/modal/AlbumPicker.vue +++ b/src/components/modal/AlbumPicker.vue @@ -55,7 +55,7 @@ {{ n('memories', 'Removed from {n} album', 'Removed from {n} albums', deselection.size, { - n: this.deselection.size, + n: deselection.size, }) }} @@ -106,6 +106,11 @@ export default defineComponent({ default: false, }, }, + + emits: { + select: (selection: IAlbum[], deselection: IAlbum[]) => true, + }, + components: { AlbumForm, AlbumsList, diff --git a/src/components/modal/AlbumShareModal.vue b/src/components/modal/AlbumShareModal.vue index 333b683f..b2b9b17d 100644 --- a/src/components/modal/AlbumShareModal.vue +++ b/src/components/modal/AlbumShareModal.vue @@ -47,6 +47,8 @@ export default defineComponent({ AlbumCollaborators, }, + emits: [], + data: () => ({ album: null as any, show: false, @@ -58,7 +60,6 @@ export default defineComponent({ close() { this.show = false; this.album = null; - this.$emit('close'); }, async open() { diff --git a/src/components/modal/AlbumsList.vue b/src/components/modal/AlbumsList.vue index c1d4d4d0..5ae23f06 100644 --- a/src/components/modal/AlbumsList.vue +++ b/src/components/modal/AlbumsList.vue @@ -63,6 +63,10 @@ export default defineComponent({ }, }, + emits: { + click: (item: IAlbum) => true, + }, + methods: { click($event: Event, album: IAlbum) { if (!this.link) { diff --git a/src/components/modal/EditExif.vue b/src/components/modal/EditExif.vue index 224f7697..18a8bd10 100644 --- a/src/components/modal/EditExif.vue +++ b/src/components/modal/EditExif.vue @@ -50,6 +50,10 @@ export default defineComponent({ }, }, + emits: { + save: () => true, + }, + data: () => ({ exif: null as Record | null, dirty: {} as Record, diff --git a/src/components/modal/FaceDeleteModal.vue b/src/components/modal/FaceDeleteModal.vue index 8946c8d9..d7f58f54 100644 --- a/src/components/modal/FaceDeleteModal.vue +++ b/src/components/modal/FaceDeleteModal.vue @@ -35,6 +35,8 @@ export default defineComponent({ Modal, }, + emits: [], + data: () => ({ show: false, user: '', @@ -54,7 +56,6 @@ export default defineComponent({ methods: { close() { this.show = false; - this.$emit('close'); }, open() { diff --git a/src/components/modal/FaceEditModal.vue b/src/components/modal/FaceEditModal.vue index 75c75702..4a035b87 100644 --- a/src/components/modal/FaceEditModal.vue +++ b/src/components/modal/FaceEditModal.vue @@ -45,6 +45,8 @@ export default defineComponent({ Modal, }, + emits: [], + data: () => ({ show: false, user: '', @@ -71,7 +73,6 @@ export default defineComponent({ methods: { close() { this.show = false; - this.$emit('close'); }, open() { diff --git a/src/components/modal/FaceList.vue b/src/components/modal/FaceList.vue index 58dec743..fde058ce 100644 --- a/src/components/modal/FaceList.vue +++ b/src/components/modal/FaceList.vue @@ -54,6 +54,10 @@ export default defineComponent({ }, }, + emits: { + select: (face: IFace) => true, + }, + data: () => ({ user: String(), name: String(), @@ -80,10 +84,6 @@ export default defineComponent({ }, methods: { - close() { - this.$emit('close'); - }, - async refreshParams() { this.user = this.$route.params.user || ''; this.name = this.$route.params.name || ''; diff --git a/src/components/modal/FaceMergeModal.vue b/src/components/modal/FaceMergeModal.vue index f6b5ecf1..a119c457 100644 --- a/src/components/modal/FaceMergeModal.vue +++ b/src/components/modal/FaceMergeModal.vue @@ -48,6 +48,8 @@ export default defineComponent({ FaceList, }, + emits: [], + data: () => ({ processing: 0, processingTotal: 0, @@ -57,7 +59,6 @@ export default defineComponent({ methods: { close() { this.show = false; - this.$emit('close'); }, open() { diff --git a/src/components/modal/FaceMoveModal.vue b/src/components/modal/FaceMoveModal.vue index 35202fe3..491441b4 100644 --- a/src/components/modal/FaceMoveModal.vue +++ b/src/components/modal/FaceMoveModal.vue @@ -41,6 +41,8 @@ export default defineComponent({ FaceList, }, + emits: [], + data: () => ({ show: false, photos: [] as IPhoto[], @@ -76,7 +78,6 @@ export default defineComponent({ close() { this.photos = []; this.show = false; - this.$emit('close'); }, moved(photos: IPhoto[]) { diff --git a/src/components/modal/Modal.vue b/src/components/modal/Modal.vue index 3db7ea64..85e8f44f 100644 --- a/src/components/modal/Modal.vue +++ b/src/components/modal/Modal.vue @@ -26,6 +26,8 @@ import { defineComponent } from 'vue'; import * as utils from '../../services/utils'; +import type { PropType } from 'vue'; + const NcModal = () => import('@nextcloud/vue/dist/Components/NcModal'); export default defineComponent({ @@ -40,7 +42,7 @@ export default defineComponent({ default: 'small', }, sidebar: { - type: String, + type: String as PropType, default: null, }, }, diff --git a/src/components/modal/MultiPathSelectionModal.vue b/src/components/modal/MultiPathSelectionModal.vue index 207220f0..f9550b7e 100644 --- a/src/components/modal/MultiPathSelectionModal.vue +++ b/src/components/modal/MultiPathSelectionModal.vue @@ -58,6 +58,10 @@ export default defineComponent({ }, }, + emits: { + close: (list: string[]) => true, + }, + data: () => ({ show: false, paths: [] as string[], diff --git a/src/components/modal/NodeShareModal.vue b/src/components/modal/NodeShareModal.vue index 79c6afa0..f33b4c31 100644 --- a/src/components/modal/NodeShareModal.vue +++ b/src/components/modal/NodeShareModal.vue @@ -1,5 +1,5 @@