mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2024-12-13 21:19:45 +01:00
Ensure screen saver blocker removed when window closed (#3557)
* $ Extract method for stopping screen saver blocker * ! Ensure screen saver blocker removed when window closed * * Move beforeunload event listener removal to beforeDestroy
This commit is contained in:
parent
7084f06184
commit
da6acf2599
@ -361,6 +361,8 @@ export default defineComponent({
|
||||
navigator.mediaSession.setActionHandler('play', () => this.player.play())
|
||||
navigator.mediaSession.setActionHandler('pause', () => this.player.pause())
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', this.stopPowerSaveBlocker)
|
||||
},
|
||||
beforeDestroy: function () {
|
||||
document.removeEventListener('keydown', this.keyboardShortcutHandler)
|
||||
@ -379,10 +381,8 @@ export default defineComponent({
|
||||
navigator.mediaSession.playbackState = 'none'
|
||||
}
|
||||
|
||||
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
|
||||
}
|
||||
this.stopPowerSaveBlocker()
|
||||
window.removeEventListener('beforeunload', this.stopPowerSaveBlocker)
|
||||
},
|
||||
methods: {
|
||||
initializePlayer: async function () {
|
||||
@ -595,11 +595,7 @@ export default defineComponent({
|
||||
navigator.mediaSession.playbackState = 'none'
|
||||
}
|
||||
|
||||
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
|
||||
this.powerSaveBlocker = null
|
||||
}
|
||||
this.stopPowerSaveBlocker()
|
||||
})
|
||||
|
||||
this.player.on('error', (error, message) => {
|
||||
@ -609,11 +605,7 @@ export default defineComponent({
|
||||
navigator.mediaSession.playbackState = 'none'
|
||||
}
|
||||
|
||||
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
|
||||
this.powerSaveBlocker = null
|
||||
}
|
||||
this.stopPowerSaveBlocker()
|
||||
})
|
||||
|
||||
this.player.on('play', async () => {
|
||||
@ -633,11 +625,7 @@ export default defineComponent({
|
||||
navigator.mediaSession.playbackState = 'paused'
|
||||
}
|
||||
|
||||
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
|
||||
this.powerSaveBlocker = null
|
||||
}
|
||||
this.stopPowerSaveBlocker()
|
||||
})
|
||||
|
||||
this.player.on(this.statsModalEventName, () => {
|
||||
@ -2116,6 +2104,14 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
|
||||
stopPowerSaveBlocker: function() {
|
||||
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
|
||||
this.powerSaveBlocker = null
|
||||
}
|
||||
},
|
||||
|
||||
...mapActions([
|
||||
'updateDefaultCaptionSettings',
|
||||
'parseScreenshotCustomFileName',
|
||||
|
Loading…
Reference in New Issue
Block a user