From 98bf8c029db4e2d1ed82c651081386eeb16f322c Mon Sep 17 00:00:00 2001 From: joaomgcd Date: Thu, 30 Jul 2020 11:27:07 +0100 Subject: [PATCH] Only show urgent and subject in MMS if appropriate Former-commit-id: 0e7b9d5c8f40b3a85aac4c822f791a822806ef54 --- appdashboardhelpernotifications.js | 2 +- server/servernotification.js | 1 + v2/control.js | 12 +++++++----- v2/device/device.js | 3 ++- .../controlnotificationclickhandler.js | 7 ++++++- v2/sms/conversation/controlsmsconveration.js | 10 +++++++--- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/appdashboardhelpernotifications.js b/appdashboardhelpernotifications.js index 1c5e3d3..58924d0 100644 --- a/appdashboardhelpernotifications.js +++ b/appdashboardhelpernotifications.js @@ -51,7 +51,7 @@ export class AppDashboardNotifications extends AppHelperBase{ const {NotificationInfo} = await import("./v2/notification/notificationinfo.js") this.controlNotifications.notifications = options.map(optionsSingle=>new NotificationInfo(optionsSingle,optionsSingle.device)); await this.controlNotifications.render(); - await Util.sleep(500); + await Util.sleep(50); ServerEventBus.post(new RequestResize(this.controlNotifications.notificationsListSize)); } async onRequestReplyMessage(request){ diff --git a/server/servernotification.js b/server/servernotification.js index 0ffe36e..a8f1059 100644 --- a/server/servernotification.js +++ b/server/servernotification.js @@ -63,6 +63,7 @@ class WindowNotifications extends Array{ const request = EventBus.waitFor(RequestNotificationInfo,3000); this.window = new BrowserWindow(args) + this.window.showInactive(); this.window.loadFile('index.html',{ query: { notificationpopup: true }}); if(debugging){ this.window.webContents.toggleDevTools(); diff --git a/v2/control.js b/v2/control.js index 3c74a37..e5e6b51 100644 --- a/v2/control.js +++ b/v2/control.js @@ -169,11 +169,11 @@ export class Control extends ExtendableProxy { return root; } //open - async unload(){ - await Control.unloadControls(this); + async unload(justSelf){ + await Control.unloadControls(this,justSelf); } - async dispose(){ - await this.unload(); + async dispose(justSelf){ + await this.unload(justSelf); const parent = this.root.parentElement; if(!parent) return; @@ -192,8 +192,10 @@ export class Control extends ExtendableProxy { //abstract getStyle(){} - static async unloadControls(obj){ + static async unloadControls(obj,justSelf){ await EventBus.unregister(obj); + if(justSelf) return; + for(const prop in obj){ const value = obj[prop]; // if(Util.isArray(value)){ diff --git a/v2/device/device.js b/v2/device/device.js index b1bc603..6a631e8 100644 --- a/v2/device/device.js +++ b/v2/device/device.js @@ -666,8 +666,9 @@ export class Device{ return AppContext.context.localStorage.get(this.canContactLocalNetworkKey); } get canContactViaLocalNetwork(){ - if(this.socket) return true; // return false; + if(this.socket) return true; + return this.localNetworkServerAddress ? true : false; } set canContactViaLocalNetwork(value) { diff --git a/v2/gcm/notificationclickhandler/controlnotificationclickhandler.js b/v2/gcm/notificationclickhandler/controlnotificationclickhandler.js index 08ab1ea..2588ae4 100644 --- a/v2/gcm/notificationclickhandler/controlnotificationclickhandler.js +++ b/v2/gcm/notificationclickhandler/controlnotificationclickhandler.js @@ -97,8 +97,13 @@ export class ControlNotificationClickHandler extends Control{ const index = this.controlsNotifications.findIndex(criteriaFunc); if(index < 0) return; + const controlNotification = this.controlsNotifications[index]; this.controlsNotifications.splice(index,1); - await this.render(); + if(controlNotification){ + await controlNotification.dispose(true); + }else{ + await this.render(); + } } /** * diff --git a/v2/sms/conversation/controlsmsconveration.js b/v2/sms/conversation/controlsmsconveration.js index e616968..fd44d5a 100644 --- a/v2/sms/conversation/controlsmsconveration.js +++ b/v2/sms/conversation/controlsmsconveration.js @@ -122,7 +122,11 @@ export class ControlSMSConversation extends Control{ // UtilDOM.hide(this.contactPictureElement); // } - this.inputElement.placeholder = `Send message to ${this.smsConversation.contact.address}`; + + const contact = this.smsConversation.contact; + if(contact){ + this.inputElement.placeholder = `Send message to ${contact.address}`; + } this.listenToEnterKey(); UtilDOM.onclickandlongclick(this.sendButtonElement, async ()=> await this.sendSms(), async () => UtilDOM.toggleShow(this.mmsExtrasElement)) @@ -201,8 +205,8 @@ export class ControlSMSMessage extends Control{ const isMMS = this.smsMessage.isMMS; UtilDOM.showOrHide(this.attachmentElement,isMMS); - UtilDOM.showOrHide(this.urgentElement,isMMS); - UtilDOM.showOrHide(this.subjectElement,isMMS); + UtilDOM.showOrHide(this.urgentElement,isMMS && this.smsMessage.urgent); + UtilDOM.showOrHide(this.subjectElement,isMMS && this.smsMessage.subject); UtilDOM.addOrRemoveClass(this.senderPictureContainerElement,!this.isLastMultiple,"invisible"); UtilDOM.addOrRemoveClass(this.containerElement,this.isLastMultiple && this.multipleReceived,"lastofmultiple"); UtilDOM.addOrRemoveClass(this.containerElement,!this.isLastMultiple && this.multipleReceived,"oneofmultiple");