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.settings = settings;
|
||||
this.pageInfo = undefined;
|
||||
}
|
||||
|
||||
setPageInfo(pageInfo){
|
||||
@ -27,6 +28,13 @@ class CommsClient {
|
||||
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") {
|
||||
this.pageInfo.setAr(message.ratio);
|
||||
} else if (message.cmd === 'set-video-float') {
|
||||
@ -282,6 +290,7 @@ class CommsServer {
|
||||
} else if (message.cmd === "set-autoar-for-site") {
|
||||
if (this.settings.active.sites[this.server.currentSite]) {
|
||||
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();
|
||||
} else {
|
||||
this.settings.active.sites[this.server.currentSite] = {
|
||||
|
@ -17,6 +17,7 @@ class PageInfo {
|
||||
|
||||
if(comms){
|
||||
this.comms = comms;
|
||||
this.comms.setPageInfo(this);
|
||||
if(this.videos.length > 0){
|
||||
comms.registerVideo();
|
||||
}
|
||||
@ -24,7 +25,7 @@ class PageInfo {
|
||||
}
|
||||
|
||||
|
||||
reset(){
|
||||
reset() {
|
||||
for(video of this.videos) {
|
||||
video.destroy();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user