signal-desktop/js/panel_controller.js
lilia e4e41140c4
Refactor app view
Introduce a top level view for navigating between the inbox and the
installer, enabling an in-window relink flow. Navigation is driven
through the openInbox and openInstaller global events.

// FREEBIE
2017-09-14 16:53:37 -07:00

56 lines
1.5 KiB
JavaScript

/*global $, Whisper, Backbone, extension*/
/*
* vim: ts=4:sw=4:expandtab
*/
// This script should only be included in background.html
(function () {
'use strict';
window.Whisper = window.Whisper || {};
window.isOpen = function() {
return true;
};
window.drawAttention = function() {
if (isOpen() && !isFocused()) {
if (window.keepClear) {
clearInterval(window.keepClear);
delete window.keepClear;
}
console.log('draw attention');
extension.windows.drawAttention(inboxWindowId);
}
};
window.clearAttention = function() {
console.log('clear attention');
if (window.keepClear) {
clearInterval(window.keepClear);
delete window.keepClear;
}
window.keepClear = setInterval(function() {
extension.windows.clearAttention(inboxWindowId);
}, 2000);
};
var inboxWindowId = 'inbox';
window.openInbox = function(options) {
Whisper.events.trigger('openInbox', options);
};
window.setUnreadCount = function(count) {
if (count > 0) {
extension.navigator.setBadgeText(count);
window.document.title = "Signal (" + count + ")";
} else {
extension.navigator.setBadgeText("");
window.document.title = "Signal";
}
};
window.openConversation = function(conversation) {
Whisper.events.trigger('openConversation', conversation);
};
})();