From 5329f0a6006f033f2686494eb710552cb2378a14 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 3 Jul 2019 22:35:17 +0200 Subject: [PATCH] Show warning when some frames on a given site are disabled --- src/ext/lib/Settings.js | 2 +- src/popup/App.vue | 50 ++++++++++++++++++--------------- src/popup/panels/VideoPanel.vue | 12 +++++++- src/res/css/common.scss | 6 ++-- 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/src/ext/lib/Settings.js b/src/ext/lib/Settings.js index 19f28af..21238eb 100644 --- a/src/ext/lib/Settings.js +++ b/src/ext/lib/Settings.js @@ -290,7 +290,7 @@ class Settings { // } try{ // if site is not defined, we use default mode: - if (! this.active.sites[site]) { + if (! this.active.sites[site] || this.active.sites[site].mode === ExtensionMode.Default) { return this.active.sites['@global'].mode === ExtensionMode.Enabled; } diff --git a/src/popup/App.vue b/src/popup/App.vue index 9ef611e..637c6cd 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -133,6 +133,7 @@
this.updateConfig()), siteTabDisabled: false, videoTabDisabled: false, - } - }, - computed: { - canShowVideoTab() { - let canShow = false; - let warning = false; - let t; - - if (!this.settings) { - return {canShow: true, warning: false}; - } - for (const site of this.activeSites) { - t = this.settings.canStartExtension(site.host); - canShow = canShow || t; - warning = warning || !t; - } - if (t === undefined) { - // something isn't the way it should be. Show sites. - return {canShow: true, warning: true}; - } - - return {canShow, warning} + canShowVideoTab: {canShow: true, warning: true}, } }, async created() { @@ -282,6 +262,29 @@ export default { }, async updateConfig() { + // when this runs, a site could have been enabled or disabled + // this means we must update canShowVideoTab + this.updateCanShowVideoTab(); + }, + updateCanShowVideoTab() { + let canShow = false; + let warning = false; + let t; + + if (!this.settings) { + this.canShowVideoTab = {canShow: true, warning: false}; + } + for (const site of this.activeSites) { + t = this.settings.canStartExtension(site.host); + canShow = canShow || t; + warning = warning || !t; + } + if (t === undefined) { + // something isn't the way it should be. Show sites. + this.canShowVideoTab = {canShow: true, warning: true}; + } + + this.canShowVideoTab = {canShow: canShow, warning: warning}; }, processReceivedMessage(message, port) { if (Debug.debug && Debug.comms) { @@ -418,6 +421,9 @@ return true; }); } } + + // update whether video tab can be shown + this.updateCanShowVideoTab(); }, getRandomColor() { return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`; diff --git a/src/popup/panels/VideoPanel.vue b/src/popup/panels/VideoPanel.vue index 121c6ee..18ea984 100644 --- a/src/popup/panels/VideoPanel.vue +++ b/src/popup/panels/VideoPanel.vue @@ -1,5 +1,8 @@