Skip to content

Commit

Permalink
* Update top nav to move query text to new window instead of remainin…
Browse files Browse the repository at this point in the history
…g in old window
  • Loading branch information
PikachuEXE committed Aug 6, 2024
1 parent 1c33170 commit f0b8fe3
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/renderer/components/top-nav/top-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default defineComponent({
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)
},
methods: {
goToSearch: async function (query, { event }) {
goToSearch: async function (queryText, { event }) {
const doCreateNewWindow = event && event.shiftKey

if (window.innerWidth <= MOBILE_WIDTH_THRESHOLD) {
Expand All @@ -148,7 +148,7 @@ export default defineComponent({

clearLocalSearchSuggestionsSession()

this.getYoutubeUrlInfo(query).then((result) => {
this.getYoutubeUrlInfo(queryText).then((result) => {
switch (result.urlType) {
case 'video': {
const { videoId, timestamp, playlistId } = result
Expand All @@ -164,7 +164,8 @@ export default defineComponent({
openInternalPath({
path: `/watch/${videoId}`,
query,
doCreateNewWindow
doCreateNewWindow,
searchQueryText: queryText,
})
break
}
Expand All @@ -175,7 +176,8 @@ export default defineComponent({
openInternalPath({
path: `/playlist/${playlistId}`,
query,
doCreateNewWindow
doCreateNewWindow,
searchQueryText: queryText,
})
break
}
Expand All @@ -187,7 +189,7 @@ export default defineComponent({
path: `/search/${encodeURIComponent(searchQuery)}`,
query,
doCreateNewWindow,
searchQueryText: searchQuery
searchQueryText: searchQuery,
})
break
}
Expand All @@ -196,7 +198,8 @@ export default defineComponent({
const { hashtag } = result
openInternalPath({
path: `/hashtag/${encodeURIComponent(hashtag)}`,
doCreateNewWindow
doCreateNewWindow,
searchQueryText: `#${hashtag}`,
})

break
Expand All @@ -209,16 +212,17 @@ export default defineComponent({
path: `/channel/${channelId}/${subPath}`,
doCreateNewWindow,
query: {
url
}
url,
},
searchQueryText: queryText,
})
break
}

case 'invalid_url':
default: {
openInternalPath({
path: `/search/${encodeURIComponent(query)}`,
path: `/search/${encodeURIComponent(queryText)}`,
query: {
sortBy: this.searchSettings.sortBy,
time: this.searchSettings.time,
Expand All @@ -227,10 +231,15 @@ export default defineComponent({
features: this.searchSettings.features,
},
doCreateNewWindow,
searchQueryText: query
searchQueryText: queryText,
})
}
}

if (doCreateNewWindow) {
// Query text copied to new window = can be removed from current window
this.updateSearchInputText('')
}
})
},

Expand Down

0 comments on commit f0b8fe3

Please sign in to comment.