Some more attempts at making comms/setting saving behave
This commit is contained in:
parent
107c9b12bd
commit
1feeaed257
@ -28,7 +28,7 @@ class CommsClient {
|
|||||||
console.log("[CommsClient.js::processMessage] Received message from background script!", message);
|
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){
|
if(Debug.debug && Debug.comms){
|
||||||
console.log("[CommsClient.js::processMessage] this.pageInfo not defined. Extension is probably disabled for this site.");
|
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){
|
processReceivedMessage(message, port){
|
||||||
if (Debug.debug && Debug.comms) {
|
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') {
|
if (message.cmd === 'get-config') {
|
||||||
|
@ -5,6 +5,16 @@ class Settings {
|
|||||||
this.default = ExtensionConf;
|
this.default = ExtensionConf;
|
||||||
this.useSync = false;
|
this.useSync = false;
|
||||||
this.version = undefined;
|
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() {
|
async init() {
|
||||||
@ -72,6 +82,10 @@ class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async set(extensionConf) {
|
async set(extensionConf) {
|
||||||
|
if (Debug.debug) {
|
||||||
|
console.log("[Settings::set] setting new settings:", extensionConf)
|
||||||
|
}
|
||||||
|
|
||||||
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
||||||
extensionConf.version = this.version;
|
extensionConf.version = this.version;
|
||||||
return this.useSync ? browser.storage.sync.set( {'uwSettings': JSON.stringify(extensionConf)}): browser.storage.local.set( {'uwSettings': JSON.stringify(extensionConf)});
|
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() {
|
async save() {
|
||||||
|
if (Debug.debug) {
|
||||||
|
console.log("[Settings::save] Saving active settings:", this.active);
|
||||||
|
}
|
||||||
|
|
||||||
this.set(this.active);
|
this.set(this.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class VideoData {
|
|||||||
this.resizer.destroy();
|
this.resizer.destroy();
|
||||||
}
|
}
|
||||||
if(this.player){
|
if(this.player){
|
||||||
player.destroy();
|
this.player.destroy();
|
||||||
}
|
}
|
||||||
this.video = null;
|
this.video = null;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class PageInfo {
|
|||||||
|
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
for(video of this.videos) {
|
for(var video of this.videos) {
|
||||||
video.destroy();
|
video.destroy();
|
||||||
}
|
}
|
||||||
this.rescan(RescanReason.MANUAL);
|
this.rescan(RescanReason.MANUAL);
|
||||||
|
Loading…
Reference in New Issue
Block a user