From 82c92d33dcfcc8785e27a62fe00393abb714e15d Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 28 Nov 2024 08:27:59 +0800 Subject: [PATCH] $ Change code style --- .../ChannelDetails/ChannelDetails.vue | 2 +- src/renderer/views/Channel/Channel.js | 28 +++++++++++-------- src/renderer/views/Channel/Channel.vue | 2 +- src/renderer/views/History/History.js | 18 +++++++----- src/renderer/views/Playlist/Playlist.js | 12 ++++---- .../views/UserPlaylists/UserPlaylists.js | 18 +++++++----- 6 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/renderer/components/ChannelDetails/ChannelDetails.vue b/src/renderer/components/ChannelDetails/ChannelDetails.vue index 33f5f1aaad832..50659bdf5c892 100644 --- a/src/renderer/components/ChannelDetails/ChannelDetails.vue +++ b/src/renderer/components/ChannelDetails/ChannelDetails.vue @@ -207,7 +207,7 @@ v-if="showSearchBar" ref="searchBar" :placeholder="$t('Channel.Search Channel')" - :value="props.query" + :value="query" :show-clear-text-button="true" class="channelSearch" :maxlength="255" diff --git a/src/renderer/views/Channel/Channel.js b/src/renderer/views/Channel/Channel.js index 2366f25bf9476..cd6d71553554a 100644 --- a/src/renderer/views/Channel/Channel.js +++ b/src/renderer/views/Channel/Channel.js @@ -2039,31 +2039,35 @@ export default defineComponent({ async saveStateInRouter(query) { this.skipRouteChangeWatcherOnce = true if (query === '') { - await this.$router.replace({ path: `/channel/${this.id}` }).catch(failure => { + try { + await this.$router.replace({ path: `/channel/${this.id}` }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } return } - await this.$router.replace({ - path: `/channel/${this.id}`, - params: { - currentTab: 'search', - }, - query: { - searchQueryText: query, - }, - }).catch(failure => { + try { + await this.$router.replace({ + path: `/channel/${this.id}`, + params: { + currentTab: 'search', + }, + query: { + searchQueryText: query, + }, + }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } this.skipRouteChangeWatcherOnce = false }, diff --git a/src/renderer/views/Channel/Channel.vue b/src/renderer/views/Channel/Channel.vue index 61f1b9ca1a5cd..d97d500a05b2f 100644 --- a/src/renderer/views/Channel/Channel.vue +++ b/src/renderer/views/Channel/Channel.vue @@ -20,7 +20,7 @@ :query="lastSearchQuery" class="card channelDetails" @change-tab="changeTab" - @search="(v) => newSearchWithStatePersist(v)" + @search="newSearchWithStatePersist" @subscribed="handleSubscription" /> { + try { + await this.$router.replace({ name: 'history' }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } return } @@ -167,16 +169,18 @@ export default defineComponent({ searchDataLimit: searchDataLimit, } if (doCaseSensitiveSearch) { routerQuery.doCaseSensitiveSearch = 'true' } - await this.$router.replace({ - name: 'history', - query: routerQuery, - }).catch(failure => { + try { + await this.$router.replace({ + name: 'history', + query: routerQuery, + }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } }, keyboardShortcutHandler: function (event) { diff --git a/src/renderer/views/Playlist/Playlist.js b/src/renderer/views/Playlist/Playlist.js index 2b3134cb3b0ca..1da0e7aa5d44d 100644 --- a/src/renderer/views/Playlist/Playlist.js +++ b/src/renderer/views/Playlist/Playlist.js @@ -624,16 +624,18 @@ export default defineComponent({ routeQuery.searchQueryText = query } - await this.$router.replace({ - path: `/playlist/${this.playlistId}`, - query: routeQuery, - }).catch(failure => { + try { + await this.$router.replace({ + path: `/playlist/${this.playlistId}`, + query: routeQuery, + }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } }, getIconForSortPreference: (s) => getIconForSortPreference(s), diff --git a/src/renderer/views/UserPlaylists/UserPlaylists.js b/src/renderer/views/UserPlaylists/UserPlaylists.js index 46f9763304621..25deadd856017 100644 --- a/src/renderer/views/UserPlaylists/UserPlaylists.js +++ b/src/renderer/views/UserPlaylists/UserPlaylists.js @@ -281,13 +281,15 @@ export default defineComponent({ async saveStateInRouter({ query = this.query, searchDataLimit = this.searchDataLimit, doSearchPlaylistsWithMatchingVideos = this.doSearchPlaylistsWithMatchingVideos } = {}) { if (this.query === '') { - await this.$router.replace({ name: 'userPlaylists' }).catch(failure => { + try { + await this.$router.replace({ name: 'userPlaylists' }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } return } @@ -296,16 +298,18 @@ export default defineComponent({ searchDataLimit: searchDataLimit, } if (doSearchPlaylistsWithMatchingVideos) { routerQuery.doSearchPlaylistsWithMatchingVideos = 'true' } - await this.$router.replace({ - name: 'userPlaylists', - query: routerQuery, - }).catch(failure => { + try { + await this.$router.replace({ + name: 'userPlaylists', + query: routerQuery, + }) + } catch (failure) { if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { return } throw failure - }) + } }, keyboardShortcutHandler: function (event) {