Comms: accounted for the possibility of pageInfo missing when extension is disabled
This commit is contained in:
parent
2619b02263
commit
107c9b12bd
@ -16,6 +16,7 @@ class CommsClient {
|
|||||||
this.port.onMessage.addListener(m => ths.processReceivedMessage(m));
|
this.port.onMessage.addListener(m => ths.processReceivedMessage(m));
|
||||||
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
this.pageInfo = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPageInfo(pageInfo){
|
setPageInfo(pageInfo){
|
||||||
@ -27,6 +28,13 @@ 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(Debug.debug && Debug.comms){
|
||||||
|
console.log("[CommsClient.js::processMessage] this.pageInfo not defined. Extension is probably disabled for this site.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.cmd === "set-ar") {
|
if (message.cmd === "set-ar") {
|
||||||
this.pageInfo.setAr(message.ratio);
|
this.pageInfo.setAr(message.ratio);
|
||||||
} else if (message.cmd === 'set-video-float') {
|
} else if (message.cmd === 'set-video-float') {
|
||||||
@ -282,6 +290,7 @@ class CommsServer {
|
|||||||
} else if (message.cmd === "set-autoar-for-site") {
|
} else if (message.cmd === "set-autoar-for-site") {
|
||||||
if (this.settings.active.sites[this.server.currentSite]) {
|
if (this.settings.active.sites[this.server.currentSite]) {
|
||||||
this.settings.active.sites[this.server.currentSite].arStatus = message.mode;
|
this.settings.active.sites[this.server.currentSite].arStatus = message.mode;
|
||||||
|
console.log("SAVING AUTOAR MODE FOR SITE", this.server.currentSite, "\nnew site obj",this.settings.active.sites[this.server.currentSite] )
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
} else {
|
} else {
|
||||||
this.settings.active.sites[this.server.currentSite] = {
|
this.settings.active.sites[this.server.currentSite] = {
|
||||||
|
@ -17,6 +17,7 @@ class PageInfo {
|
|||||||
|
|
||||||
if(comms){
|
if(comms){
|
||||||
this.comms = comms;
|
this.comms = comms;
|
||||||
|
this.comms.setPageInfo(this);
|
||||||
if(this.videos.length > 0){
|
if(this.videos.length > 0){
|
||||||
comms.registerVideo();
|
comms.registerVideo();
|
||||||
}
|
}
|
||||||
@ -24,7 +25,7 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
reset(){
|
reset() {
|
||||||
for(video of this.videos) {
|
for(video of this.videos) {
|
||||||
video.destroy();
|
video.destroy();
|
||||||
}
|
}
|
||||||
|
1
js/uw.js
1
js/uw.js
@ -57,7 +57,6 @@ async function init(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
pageInfo = new PageInfo(comms, settings);
|
pageInfo = new PageInfo(comms, settings);
|
||||||
comms.setPageInfo(pageInfo);
|
|
||||||
|
|
||||||
if(Debug.debug){
|
if(Debug.debug){
|
||||||
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo);
|
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user