diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index b34630f3f8..7b178f53a2 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -85,6 +85,7 @@ var PLAY_NOTIFICATION_SOUNDS_SETTING = "play_notification_sounds"; var PLAY_NOTIFICATION_SOUNDS_TYPE_SETTING_PRE = "play_notification_sounds_type_"; var lodTextID = false; + var NOTIFICATIONS_MESSAGE_CHANNEL = "Hifi-Notifications" var NotificationType = { UNKNOWN: 0, @@ -531,6 +532,13 @@ createNotification(wordWrap(msg), NotificationType.UNKNOWN); // Needs a generic notification system for user feedback, thus using this } + function onMessageReceived(channel, message) { + if (channel === NOTIFICATIONS_MESSAGE_CHANNEL) { + message = JSON.parse(message); + createNotification(wordWrap(message.message), message.notificationType); + } + } + function onSnapshotTaken(pathStillSnapshot, notify) { if (notify) { var imageProperties = { @@ -623,6 +631,7 @@ Overlays.deleteOverlay(buttons[notificationIndex]); } Menu.removeMenu(MENU_NAME); + Messages.unsubscribe(NOTIFICATIONS_MESSAGE_CHANNEL); } function menuItemEvent(menuItem) { @@ -665,6 +674,10 @@ Window.notifyEditError = onEditError; Window.notify = onNotify; Tablet.tabletNotification.connect(tabletNotification); + + Messages.subscribe(NOTIFICATIONS_MESSAGE_CHANNEL); + Messages.messageReceived.connect(onMessageReceived); + setup(); }()); // END LOCAL_SCOPE diff --git a/scripts/vr-edit/vr-edit.js b/scripts/vr-edit/vr-edit.js index 31920d668b..4bb70134b8 100644 --- a/scripts/vr-edit/vr-edit.js +++ b/scripts/vr-edit/vr-edit.js @@ -1590,9 +1590,18 @@ function onAppButtonClicked() { + var NOTIFICATIONS_MESSAGE_CHANNEL = "Hifi-Notifications", + EDIT_ERROR = 4, // Per notifications.js. + INSUFFICIENT_PERMISSIONS_ERROR_MSG = + "You do not have the necessary permissions to edit on this domain."; // Same as edit.js. + // Application tablet/toolbar button clicked. if (!isAppActive && !(Entities.canRez() || Entities.canRezTmp())) { Feedback.play(dominantHand, Feedback.GENERAL_ERROR); + Messages.sendLocalMessage(NOTIFICATIONS_MESSAGE_CHANNEL, JSON.stringify({ + message: INSUFFICIENT_PERMISSIONS_ERROR_MSG, + notificationType: EDIT_ERROR + })); return; }