Don't wake up to check messages if not registered
This chrome alarm business is in place to help us wake up and check for messages when running in the background. Without it, chrome will suspend our app after a short period of inactivity. Upon waking, if the app discovers it is not linked, it prompts you to link it. However, if you've declined registration (i.e., because you already maxed out your linked device limit, but chrome auto-added the app to another machine), we should just wait until explicitly launched again. Fixes #519 // FREEBIE
This commit is contained in:
parent
d201c65f7c
commit
51fc10abb6
2 changed files with 11 additions and 6 deletions
|
@ -23,12 +23,6 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
if (chrome && chrome.alarms) {
|
||||
chrome.alarms.onAlarm.addListener(function() {
|
||||
// nothing to do.
|
||||
});
|
||||
chrome.alarms.create('awake', {periodInMinutes: 1});
|
||||
}
|
||||
|
||||
// Close and reopen existing windows
|
||||
var open = false;
|
||||
|
@ -74,10 +68,12 @@
|
|||
setUnreadCount(storage.get("unreadCount", 0));
|
||||
|
||||
if (textsecure.registration.isDone()) {
|
||||
extension.keepAwake();
|
||||
init();
|
||||
}
|
||||
|
||||
extension.on('registration_done', function() {
|
||||
extension.keepAwake();
|
||||
init(true);
|
||||
});
|
||||
|
||||
|
|
|
@ -231,6 +231,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
extension.keepAwake = function() {
|
||||
if (chrome && chrome.alarms) {
|
||||
chrome.alarms.onAlarm.addListener(function() {
|
||||
// nothing to do.
|
||||
});
|
||||
chrome.alarms.create('awake', {periodInMinutes: 1});
|
||||
}
|
||||
};
|
||||
|
||||
if (chrome.runtime.onInstalled) {
|
||||
chrome.runtime.onInstalled.addListener(function(options) {
|
||||
if (options.reason === 'install') {
|
||||
|
|
Loading…
Reference in a new issue