From 4203ff4ba3a90e84c723d9e58cef3be5cdcd1573 Mon Sep 17 00:00:00 2001 From: Preston Date: Thu, 20 Aug 2020 21:20:22 -0400 Subject: [PATCH] Fix some navigation, clear data on exit, and add more toast messages --- src/main/index.js | 14 ++++++++++++ src/renderer/App.js | 12 +++++----- .../components/ft-list-video/ft-list-video.js | 9 ++++++++ src/renderer/main.js | 10 --------- src/renderer/views/Watch/Watch.js | 22 +++++++++++-------- 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index e9a2e3d6..de8b35b5 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -116,6 +116,20 @@ app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit() } + + mainWindow.webContents.session.clearCache() + mainWindow.webContents.session.clearStorageData({ + storages: [ + 'appcache', + 'cookies', + 'filesystem', + 'indexdb', + 'shadercache', + 'websql', + 'serviceworkers', + 'cachestorage' + ] + }) }) app.on('activate', () => { diff --git a/src/renderer/App.js b/src/renderer/App.js index d74d3262..9b24001d 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -42,12 +42,12 @@ export default Vue.extend({ this.openAllLinksExternally() } - try { - const doc = yaml.safeLoad(fs.readFileSync('./static/locales/en-US.yaml')) - console.log(doc) - } catch (e) { - console.log(e) - } + // try { + // const doc = yaml.safeLoad(fs.readFileSync('./static/locales/en-US.yaml')) + // console.log(doc) + // } catch (e) { + // console.log(e) + // } }, methods: { checkLocale: function () { diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index e7622555..da3825f7 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -174,6 +174,9 @@ export default Vue.extend({ break case 'copyYoutube': navigator.clipboard.writeText(this.youtubeUrl) + this.showToast({ + message: this.$t('Share.YouTube URL copied to clipboard') + }) break case 'openYoutube': if (this.usingElectron) { @@ -183,6 +186,9 @@ export default Vue.extend({ break case 'copyYoutubeEmbed': navigator.clipboard.writeText(this.youtubeEmbedUrl) + this.showToast({ + message: this.$t('Share.YouTube Embed URL copied to clipboard') + }) break case 'openYoutubeEmbed': if (this.usingElectron) { @@ -192,6 +198,9 @@ export default Vue.extend({ break case 'copyInvidious': navigator.clipboard.writeText(this.invidiousUrl) + this.showToast({ + message: this.$t('Share.Invidious URL copied to clipboard') + }) break case 'openInvidious': if (this.usingElectron) { diff --git a/src/renderer/main.js b/src/renderer/main.js index 8a8031bb..d183e388 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -22,16 +22,6 @@ library.add(fas) Vue.component('font-awesome-icon', FontAwesomeIcon) Vue.use(VueI18n) -fs.readdir('.', (err, dir) => { - if (err) { - console.log(err) - } - console.log(dir) - for (const filePath of dir) { - console.log(filePath) - } -}) - // List of locales approved for use const activeLocales = ['en-US', 'de-DE', 'pt-PT'] const messages = {} diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index ac63c2ec..72e4fa72 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -687,16 +687,20 @@ export default Vue.extend({ ]) }, beforeRouteLeave: function (to, from, next) { - if (this.rememberHistory) { - const currentTime = this.$refs.videoPlayer.player.currentTime() - console.log(currentTime) - const payload = { - videoId: this.videoId, - watchProgress: currentTime - } + if (this.rememberHistory && !this.isLoading && !this.isLive) { + const player = this.$refs.videoPlayer.player - console.log('update watch progress') - this.updateWatchProgress(payload) + if (typeof player !== 'undefined') { + const currentTime = this.$refs.videoPlayer.player.currentTime() + console.log(currentTime) + const payload = { + videoId: this.videoId, + watchProgress: currentTime + } + + console.log('update watch progress') + this.updateWatchProgress(payload) + } } next()