Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ const IpcChannels = {
CREATE_NEW_WINDOW: 'create-new-window',
OPEN_IN_EXTERNAL_PLAYER: 'open-in-external-player',
NATIVE_THEME_UPDATE: 'native-theme-update',
APP_READY: 'app-ready',
RELAUNCH_REQUEST: 'relaunch-request',

SEARCH_INPUT_HANDLING_READY: 'search-input-handling-ready',
UPDATE_SEARCH_INPUT_TEXT: 'update-search-input-text',

OPEN_URL: 'open-url',
CHANGE_VIEW: 'change-view',

HISTORY_BACK: 'history-back',
HISTORY_FORWARD: 'history-forward',

DB_SETTINGS: 'db-settings',
DB_HISTORY: 'db-history',
Expand All @@ -26,6 +37,8 @@ const IpcChannels = {
GET_REPLACE_HTTP_CACHE: 'get-replace-http-cache',
TOGGLE_REPLACE_HTTP_CACHE: 'toggle-replace-http-cache',

SHOW_VIDEO_STATISTICS: 'show-video-statistics',

PLAYER_CACHE_GET: 'player-cache-get',
PLAYER_CACHE_SET: 'player-cache-set'
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function runApp() {
label: 'Show / Hide Video Statistics',
visible: parameters.mediaType === 'video',
click: () => {
browserWindow.webContents.send('showVideoStatistics')
browserWindow.webContents.send(IpcChannels.SHOW_VIDEO_STATISTICS)
}
},
{
Expand Down Expand Up @@ -243,7 +243,7 @@ function runApp() {

const url = getLinkUrl(commandLine)
if (url) {
mainWindow.webContents.send('openUrl', url)
mainWindow.webContents.send(IpcChannels.OPEN_URL, url)
}
}
})
Expand Down Expand Up @@ -745,8 +745,8 @@ function runApp() {
}

if (typeof searchQueryText === 'string' && searchQueryText.length > 0) {
ipcMain.once('searchInputHandlingReady', () => {
newWindow.webContents.send('updateSearchInputText', searchQueryText)
ipcMain.once(IpcChannels.SEARCH_INPUT_HANDLING_READY, () => {
newWindow.webContents.send(IpcChannels.UPDATE_SEARCH_INPUT_TEXT, searchQueryText)
})
}

Expand Down Expand Up @@ -792,9 +792,9 @@ function runApp() {
})
}

ipcMain.once('appReady', () => {
ipcMain.once(IpcChannels.APP_READY, () => {
if (startupUrl) {
mainWindow.webContents.send('openUrl', startupUrl)
mainWindow.webContents.send(IpcChannels.OPEN_URL, startupUrl)
}
})

Expand Down Expand Up @@ -831,7 +831,7 @@ function runApp() {
app.quit()
}

ipcMain.once('relaunchRequest', () => {
ipcMain.once(IpcChannels.RELAUNCH_REQUEST, () => {
relaunch()
})

Expand Down Expand Up @@ -1306,7 +1306,7 @@ function runApp() {
event.preventDefault()

if (mainWindow && mainWindow.webContents) {
mainWindow.webContents.send('openUrl', baseUrl(url))
mainWindow.webContents.send(IpcChannels.OPEN_URL, baseUrl(url))
} else {
startupUrl = baseUrl(url)
}
Expand Down Expand Up @@ -1367,7 +1367,7 @@ function runApp() {
}

browserWindow.webContents.send(
'change-view',
IpcChannels.CHANGE_VIEW,
{ route: path }
)
}
Expand Down Expand Up @@ -1469,7 +1469,7 @@ function runApp() {
if (browserWindow == null) { return }

browserWindow.webContents.send(
'history-back',
IpcChannels.HISTORY_BACK
)
},
type: 'normal',
Expand All @@ -1481,7 +1481,7 @@ function runApp() {
if (browserWindow == null) { return }

browserWindow.webContents.send(
'history-forward',
IpcChannels.HISTORY_FORWARD
)
},
type: 'normal',
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ export default defineComponent({

activateIPCListeners: function () {
// handle menu event updates from main script
ipcRenderer.on('history-back', (_event) => {
ipcRenderer.on(IpcChannels.HISTORY_BACK, (_event) => {
this.$refs.topNav.historyBack()
})
ipcRenderer.on('history-forward', (_event) => {
ipcRenderer.on(IpcChannels.HISTORY_FORWARD, (_event) => {
this.$refs.topNav.historyForward()
})
},
Expand Down Expand Up @@ -505,23 +505,23 @@ export default defineComponent({
},

enableSetSearchQueryText: function () {
ipcRenderer.on('updateSearchInputText', (event, searchQueryText) => {
ipcRenderer.on(IpcChannels.UPDATE_SEARCH_INPUT_TEXT, (event, searchQueryText) => {
if (searchQueryText) {
this.$refs.topNav.updateSearchInputText(searchQueryText)
}
})

ipcRenderer.send('searchInputHandlingReady')
ipcRenderer.send(IpcChannels.SEARCH_INPUT_HANDLING_READY)
},

enableOpenUrl: function () {
ipcRenderer.on('openUrl', (event, url) => {
ipcRenderer.on(IpcChannels.OPEN_URL, (event, url) => {
if (url) {
this.handleYoutubeLink(url)
}
})

ipcRenderer.send('appReady')
ipcRenderer.send(IpcChannels.APP_READY)
},

handleExternalLinkOpeningPromptAnswer: function (option) {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ft-video-player/ft-video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ export default defineComponent({
// right click menu
if (process.env.IS_ELECTRON) {
const { ipcRenderer } = require('electron')
ipcRenderer.removeAllListeners('showVideoStatistics')
ipcRenderer.on('showVideoStatistics', (event) => {
ipcRenderer.removeAllListeners(IpcChannels.SHOW_VIDEO_STATISTICS)
ipcRenderer.on(IpcChannels.SHOW_VIDEO_STATISTICS, (event) => {
this.toggleShowStatsModal()
})
}
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/theme-settings/theme-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import FtSlider from '../ft-slider/ft-slider.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
import FtPrompt from '../ft-prompt/ft-prompt.vue'
import { colors, getColorTranslations } from '../../helpers/colors'
import { IpcChannels } from '../../../constants'

export default defineComponent({
name: 'ThemeSettings',
Expand Down Expand Up @@ -163,7 +164,7 @@ export default defineComponent({
this.disableSmoothScrollingToggleValue
).then(() => {
const { ipcRenderer } = require('electron')
ipcRenderer.send('relaunchRequest')
ipcRenderer.send(IpcChannels.RELAUNCH_REQUEST)
})
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import App from './App.vue'
import router from './router/index'
import store from './store/index'
import i18n from './i18n/index'
import { IpcChannels } from '../constants'
import { library } from '@fortawesome/fontawesome-svg-core'

import { register as registerSwiper } from 'swiper/element'
Expand Down Expand Up @@ -218,7 +219,7 @@ if (process.env.IS_ELECTRON) {
const { ipcRenderer } = require('electron')

// handle menu event updates from main script
ipcRenderer.on('change-view', (event, data) => {
ipcRenderer.on(IpcChannels.CHANGE_VIEW, (event, data) => {
if (data.route) {
router.push(data.route)
}
Expand Down