Save incoming messages and pass to frontend asynchronously
After a message is saved asynchronsly, fire an event and pass the message attributes to frontend listeners via the chrome-runtime API. This behavior is similar to the 'storage' event fired by localStorage.
This commit is contained in:
parent
ced295a630
commit
470346c9c4
9 changed files with 110 additions and 85 deletions
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
// Browser specific functions for Chrom*
|
||||
window.extension = window.extension || {};
|
||||
|
||||
window.extension.navigator = (function () {
|
||||
|
@ -33,7 +34,17 @@
|
|||
return self;
|
||||
}());
|
||||
|
||||
// Random shared utilities that are used only by chromium things
|
||||
window.extension.trigger = function (name, object) {
|
||||
chrome.runtime.sendMessage(null, { name: name, data: object });
|
||||
};
|
||||
|
||||
window.extension.onMessage = function (name, callback) {
|
||||
chrome.runtime.onMessage.addListener(function(e) {
|
||||
if (e.name === name) {
|
||||
callback(e.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.registration = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue