diff --git a/src/main/index.js b/src/main/index.js index d6fe8070a..147fb8aaf 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -170,7 +170,13 @@ function runApp() { } } - async function createWindow({ replaceMainWindow = true, windowStartupUrl = null, showWindowNow = false } = { }) { + async function createWindow( + { + replaceMainWindow = true, + windowStartupUrl = null, + showWindowNow = false, + searchQueryText = null + } = { }) { // Syncing new window background to theme choice. const windowBackground = await baseHandlers.settings._findTheme().then(({ value }) => { switch (value) { @@ -302,6 +308,12 @@ function runApp() { .replace(/\\/g, '\\\\') } + if (typeof searchQueryText === 'string' && searchQueryText.length > 0) { + ipcMain.once('searchInputHandlingReady', () => { + newWindow.webContents.send('updateSearchInputText', searchQueryText) + }) + } + // Show when loaded newWindow.once('ready-to-show', () => { if (newWindow.isVisible()) { @@ -445,11 +457,12 @@ function runApp() { return powerSaveBlocker.start('prevent-display-sleep') }) - ipcMain.on(IpcChannels.CREATE_NEW_WINDOW, (_e, { windowStartupUrl = null } = { }) => { + ipcMain.on(IpcChannels.CREATE_NEW_WINDOW, (_e, { windowStartupUrl = null, searchQueryText = null } = { }) => { createWindow({ replaceMainWindow: false, showWindowNow: true, - windowStartupUrl: windowStartupUrl + windowStartupUrl: windowStartupUrl, + searchQueryText: searchQueryText }) }) diff --git a/src/renderer/App.js b/src/renderer/App.js index c1e06bcdf..62467cfa7 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -160,6 +160,7 @@ export default Vue.extend({ this.setupListenersToSyncWindows() this.activateKeyboardShortcuts() this.openAllLinksExternally() + this.enableSetSearchQueryText() this.enableOpenUrl() this.watchSystemTheme() await this.checkExternalPlayer() @@ -408,7 +409,8 @@ export default Vue.extend({ this.openInternalPath({ path, query, - doCreateNewWindow + doCreateNewWindow, + searchQueryText: searchQuery }) break } @@ -467,7 +469,7 @@ export default Vue.extend({ }) }, - openInternalPath: function({ path, doCreateNewWindow, query = {} }) { + openInternalPath: function({ path, doCreateNewWindow, query = {}, searchQueryText = null }) { if (process.env.IS_ELECTRON && doCreateNewWindow) { const { ipcRenderer } = require('electron') @@ -477,7 +479,8 @@ export default Vue.extend({ `#${path}?${(new URLSearchParams(query)).toString()}` ].join('') ipcRenderer.send(IpcChannels.CREATE_NEW_WINDOW, { - windowStartupUrl: newWindowStartupURL + windowStartupUrl: newWindowStartupURL, + searchQueryText }) } else { // Web @@ -488,6 +491,16 @@ export default Vue.extend({ } }, + enableSetSearchQueryText: function () { + ipcRenderer.on('updateSearchInputText', (event, searchQueryText) => { + if (searchQueryText) { + this.$refs.topNav.updateSearchInputText(searchQueryText) + } + }) + + ipcRenderer.send('searchInputHandlingReady') + }, + enableOpenUrl: function () { ipcRenderer.on('openUrl', (event, url) => { if (url) { diff --git a/src/renderer/components/ft-input/ft-input.js b/src/renderer/components/ft-input/ft-input.js index 6e7869d94..7196ae6b9 100644 --- a/src/renderer/components/ft-input/ft-input.js +++ b/src/renderer/components/ft-input/ft-input.js @@ -264,6 +264,10 @@ export default Vue.extend({ this.visibleDataList = visList }, + updateInputData: function(text) { + this.inputData = text + }, + ...mapActions([ 'getYoutubeUrlInfo' ]) diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js index aec4ef822..f843b8181 100644 --- a/src/renderer/components/top-nav/top-nav.js +++ b/src/renderer/components/top-nav/top-nav.js @@ -140,7 +140,8 @@ export default Vue.extend({ this.openInternalPath({ path: `/search/${encodeURIComponent(searchQuery)}`, query, - doCreateNewWindow + doCreateNewWindow, + searchQueryText: searchQuery }) break } @@ -179,7 +180,8 @@ export default Vue.extend({ type: this.searchSettings.type, duration: this.searchSettings.duration }, - doCreateNewWindow + doCreateNewWindow, + searchQueryText: query }) } } @@ -300,7 +302,7 @@ export default Vue.extend({ this.$store.commit('toggleSideNav') }, - openInternalPath: function({ path, doCreateNewWindow, query = {} }) { + openInternalPath: function({ path, doCreateNewWindow, query = {}, searchQueryText = null }) { if (process.env.IS_ELECTRON && doCreateNewWindow) { const { ipcRenderer } = require('electron') @@ -310,7 +312,8 @@ export default Vue.extend({ `#${path}?${(new URLSearchParams(query)).toString()}` ].join('') ipcRenderer.send(IpcChannels.CREATE_NEW_WINDOW, { - windowStartupUrl: newWindowStartupURL + windowStartupUrl: newWindowStartupURL, + searchQueryText }) } else { // Web @@ -335,6 +338,9 @@ export default Vue.extend({ hideFilters: function () { this.showFilters = false }, + updateSearchInputText: function(text) { + this.$refs.searchInput.updateInputData(text) + }, ...mapActions([ 'showToast', 'getYoutubeUrlInfo',