From 068819d1bc39b86af2aa4370a5c2d9d833ef7798 Mon Sep 17 00:00:00 2001 From: ThrRip Date: Thu, 21 Sep 2023 20:05:42 +0800 Subject: [PATCH] home: Cleanup code and suppress incorrect TypeScript errors --- packages/home/app.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/home/app.vue b/packages/home/app.vue index b55cebe..e6cf35d 100644 --- a/packages/home/app.vue +++ b/packages/home/app.vue @@ -408,11 +408,11 @@ function viewPlaylistToggleSorting (column: PlaylistColumn) { } else { const sortingOrderOptionIndex: number = viewPlaylistSortingOrderOptions.value.findIndex( - (option: PlaylistSortingOrder) => { return viewPlaylistSortingOrder.value === option } + (option: PlaylistSortingOrder) => viewPlaylistSortingOrder.value === option ) + 1 > viewPlaylistSortingOrderOptions.value.length - 1 ? 0 : viewPlaylistSortingOrderOptions.value.findIndex( - (option: PlaylistSortingOrder) => { return viewPlaylistSortingOrder.value === option } + (option: PlaylistSortingOrder) => viewPlaylistSortingOrder.value === option ) + 1 viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[sortingOrderOptionIndex] } @@ -462,7 +462,6 @@ const viewPlaylistData = computed(() => { return ((a.payment_amount ?? 0) - (b.payment_amount ?? 0)) * orderModifier }) } else - // Sort by language if (viewPlaylistSortingColumn.value === 'language') { playlist = backendPlaylistShuffled.value.slice() @@ -489,27 +488,28 @@ const viewPlaylistCopiedSongs = ref>([]) const viewPlaylistCopyingFailedSongs = ref>([]) function viewPlaylistCopySong (id: Song['$id']) { const clipboardWritePromise = navigator.clipboard.writeText( - `点歌 ${backendPlaylist.value.find((song: Song) => { return song.$id === id }).name}` + // @ts-ignore + `点歌 ${backendPlaylist.value.find((song: Song) => song.$id === id).name}` ) setTimeout(() => { if (!viewPlaylistCopiedSongs.value.includes(id)) { viewPlaylistCopyingFailedSongs.value.push(id) } }, 500) clipboardWritePromise.then( () => { if (viewPlaylistCopyingFailedSongs.value.includes(id)) { viewPlaylistCopyingFailedSongs.value.splice( - viewPlaylistCopyingFailedSongs.value.findIndex((songId: Song['$id']) => { return songId === id }), + viewPlaylistCopyingFailedSongs.value.findIndex((songId: Song['$id']) => songId === id), 1 ) } if (!viewPlaylistCopiedSongs.value.includes(id)) { viewPlaylistCopiedSongs.value.push(id) } setTimeout(() => viewPlaylistCopiedSongs.value.splice( - viewPlaylistCopiedSongs.value.findIndex((songId: Song['$id']) => { return songId === id }), + viewPlaylistCopiedSongs.value.findIndex((songId: Song['$id']) => songId === id), 1 ), 2000) }, () => { if (!viewPlaylistCopyingFailedSongs.value.includes(id)) { viewPlaylistCopyingFailedSongs.value.push(id) } setTimeout(() => viewPlaylistCopyingFailedSongs.value.splice( - viewPlaylistCopyingFailedSongs.value.findIndex((songId: Song['$id']) => { return songId === id }), + viewPlaylistCopyingFailedSongs.value.findIndex((songId: Song['$id']) => songId === id), 1 ), 5000) }