Some more attempts at making comms/setting saving behave

This commit is contained in:
Tamius Han 2018-08-23 01:04:37 +02:00
parent 107c9b12bd
commit 1feeaed257
4 changed files with 22 additions and 4 deletions

View File

@ -28,7 +28,7 @@ class CommsClient {
console.log("[CommsClient.js::processMessage] Received message from background script!", message);
}
if (! this.pageInfo) {
if (! this.pageInfo || this.settings.active) {
if(Debug.debug && Debug.comms){
console.log("[CommsClient.js::processMessage] this.pageInfo not defined. Extension is probably disabled for this site.");
}
@ -233,7 +233,7 @@ class CommsServer {
processReceivedMessage(message, port){
if (Debug.debug && Debug.comms) {
console.log("[CommsServer.js::processMessage] Received message from background script!", message, "port", port);
console.log("[CommsServer.js::processMessage] Received message from background script!", message, "port", port, "\nsettings and server:", this.settings,this.server);
}
if (message.cmd === 'get-config') {

View File

@ -5,6 +5,16 @@ class Settings {
this.default = ExtensionConf;
this.useSync = false;
this.version = undefined;
const ths = this;
if(BrowserDetect.firefox) {
browser.storage.onChanged.addListener( (changes, area) => {
if(changes['uwSettings'] && changes['uwSettings'].newValue) {
ths.active = JSON.parse(changes.uwSettings.newValue);
}
});
}
}
async init() {
@ -72,6 +82,10 @@ class Settings {
}
async set(extensionConf) {
if (Debug.debug) {
console.log("[Settings::set] setting new settings:", extensionConf)
}
if (BrowserDetect.firefox || BrowserDetect.edge) {
extensionConf.version = this.version;
return this.useSync ? browser.storage.sync.set( {'uwSettings': JSON.stringify(extensionConf)}): browser.storage.local.set( {'uwSettings': JSON.stringify(extensionConf)});
@ -89,6 +103,10 @@ class Settings {
}
async save() {
if (Debug.debug) {
console.log("[Settings::save] Saving active settings:", this.active);
}
this.set(this.active);
}

View File

@ -50,7 +50,7 @@ class VideoData {
this.resizer.destroy();
}
if(this.player){
player.destroy();
this.player.destroy();
}
this.video = null;
}

View File

@ -26,7 +26,7 @@ class PageInfo {
reset() {
for(video of this.videos) {
for(var video of this.videos) {
video.destroy();
}
this.rescan(RescanReason.MANUAL);