Skip to content

Commit

Permalink
Startup message counter: increment on message processing complete
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal authored and kenpowers-signal committed Oct 17, 2019
1 parent e59d095 commit 1632e19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
21 changes: 16 additions & 5 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,6 @@
addQueuedEventListener('error', onError);
addQueuedEventListener('empty', onEmpty);
addQueuedEventListener('reconnect', onReconnect);
addQueuedEventListener('progress', onProgress);
addQueuedEventListener('configuration', onConfiguration);
addQueuedEventListener('typing', onTyping);
addQueuedEventListener('sticker-pack', onStickerPack);
Expand Down Expand Up @@ -1038,15 +1037,27 @@
deliveryReceiptQueue.pause();
Whisper.Notifications.disable();
}
function onProgress(ev) {
const { count } = ev;
window.log.info(`onProgress: Message count is ${count}`);

let initialStartupCount = 0;
Whisper.events.on('incrementProgress', incrementProgress);
function incrementProgress() {
initialStartupCount += 1;

// Only update progress every 10 items
if (initialStartupCount % 10 !== 0) {
return;
}

window.log.info(
`incrementProgress: Message count is ${initialStartupCount}`
);

const view = window.owsDesktopApp.appView;
if (view) {
view.onProgress(count);
view.onProgress(initialStartupCount);
}
}

function onConfiguration(ev) {
ev.confirm();

Expand Down
1 change: 1 addition & 0 deletions js/models/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,7 @@
await conversation.notify(message);
}

Whisper.events.trigger('incrementProgress');
confirm();
} catch (error) {
const errorForLog = error && error.stack ? error.stack : error;
Expand Down

0 comments on commit 1632e19

Please sign in to comment.