diff --git a/src/main/index.js b/src/main/index.js index f2a6f16b24db..98c74fe02f1f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1366,6 +1366,11 @@ function runApp() { } function baseUrl(arg) { + // freetube.exe s="query" + if (arg.startsWith('s=')) { + return `https://www.youtube.com/results?search_query=${encodeURIComponent(arg.substring(2))}` + } + let newArg = arg.replace('freetube://', '') // add support for authority free url .replace('freetube:', '') diff --git a/src/renderer/App.js b/src/renderer/App.js index e2ecc75e4140..eed8d8890f0f 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -492,7 +492,7 @@ export default defineComponent({ enableSetSearchQueryText: function () { ipcRenderer.on(IpcChannels.UPDATE_SEARCH_INPUT_TEXT, (event, searchQueryText) => { if (searchQueryText) { - this.$refs.topNav.updateSearchInputText(searchQueryText) + this.$refs.topNav.updateSearchInputText({ detail: { query: searchQueryText } }) } }) diff --git a/src/renderer/components/top-nav/top-nav-events.js b/src/renderer/components/top-nav/top-nav-events.js new file mode 100644 index 000000000000..95b4ffbb1fe9 --- /dev/null +++ b/src/renderer/components/top-nav/top-nav-events.js @@ -0,0 +1,2 @@ +const events = new EventTarget() +export default events diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js index 0a5f16371cce..a685d883b6e6 100644 --- a/src/renderer/components/top-nav/top-nav.js +++ b/src/renderer/components/top-nav/top-nav.js @@ -2,6 +2,7 @@ import { defineComponent } from 'vue' import { mapActions } from 'vuex' import FtInput from '../ft-input/ft-input.vue' import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue' +import TopNavEvents from './top-nav-events' import debounce from 'lodash.debounce' import { IpcChannels, MOBILE_WIDTH_THRESHOLD } from '../../../constants' @@ -134,6 +135,11 @@ export default defineComponent({ }) this.debounceSearchResults = debounce(this.getSearchSuggestions, 200) + + TopNavEvents.addEventListener('updateSearchInput', this.updateSearchInputText) + }, + beforeDestroy: function () { + TopNavEvents.removeEventListener('updateSearchInput', this.updateSearchInputText) }, methods: { goToSearch: async function (query, { event }) { @@ -333,8 +339,8 @@ export default defineComponent({ navigate: function (route) { this.$router.push('/' + route) }, - updateSearchInputText: function (text) { - this.$refs.searchInput.updateInputData(text) + updateSearchInputText: function ({ detail: { query } }) { + this.$refs.searchInput.updateInputData(query) }, ...mapActions([ 'getYoutubeUrlInfo', diff --git a/src/renderer/views/Search/Search.js b/src/renderer/views/Search/Search.js index 05b26d5792b7..8d988f90c4fb 100644 --- a/src/renderer/views/Search/Search.js +++ b/src/renderer/views/Search/Search.js @@ -11,6 +11,7 @@ import { } from '../../helpers/utils' import { getLocalSearchContinuation, getLocalSearchResults } from '../../helpers/api/local' import { invidiousAPICall } from '../../helpers/api/invidious' +import TopNavEvents from '../../components/top-nav/top-nav-events' import { SEARCH_CHAR_LIMIT } from '../../../constants' export default defineComponent({ @@ -55,11 +56,14 @@ export default defineComponent({ // react to route changes... const query = this.$route.params.query + TopNavEvents.dispatchEvent(new CustomEvent('updateSearchInput', { detail: { query } })) + let features = this.$route.query.features // if page gets refreshed and there's only one feature then it will be a string if (typeof features === 'string') { features = [features] } + const searchSettings = { sortBy: this.$route.query.sortBy, time: this.$route.query.time, @@ -80,7 +84,10 @@ export default defineComponent({ } }, mounted: function () { - this.query = this.$route.params.query + const query = this.$route.params.query + + this.query = query + TopNavEvents.dispatchEvent(new CustomEvent('updateSearchInput', { detail: { query } })) let features = this.$route.query.features // if page gets refreshed and there's only one feature then it will be a string @@ -97,7 +104,7 @@ export default defineComponent({ } const payload = { - query: this.query, + query, options: {}, searchSettings: this.searchSettings }