Reduce unnecessary redux update during message receipt
This commit is contained in:
parent
95842c6e0b
commit
844613272c
1 changed files with 11 additions and 3 deletions
|
@ -2266,7 +2266,7 @@ export async function startApp(): Promise<void> {
|
||||||
maxSize: Infinity,
|
maxSize: Infinity,
|
||||||
});
|
});
|
||||||
|
|
||||||
const throttledSetInboxEnvelopeTimestamp = throttle(
|
const _throttledSetInboxEnvelopeTimestamp = throttle(
|
||||||
serverTimestamp => {
|
serverTimestamp => {
|
||||||
window.reduxActions.inbox.setInboxEnvelopeTimestamp(serverTimestamp);
|
window.reduxActions.inbox.setInboxEnvelopeTimestamp(serverTimestamp);
|
||||||
},
|
},
|
||||||
|
@ -2274,16 +2274,24 @@ export async function startApp(): Promise<void> {
|
||||||
{ leading: false }
|
{ leading: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function setInboxEnvelopeTimestamp(timestamp: number): void {
|
||||||
|
// This timestamp is only used in the loading screen UI. If the app has loaded, let's
|
||||||
|
// not set it to avoid unnecessary renders
|
||||||
|
if (!window.reduxStore.getState().app.hasInitialLoadCompleted) {
|
||||||
|
_throttledSetInboxEnvelopeTimestamp(timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function onEnvelopeQueued({
|
async function onEnvelopeQueued({
|
||||||
envelope,
|
envelope,
|
||||||
}: EnvelopeQueuedEvent): Promise<void> {
|
}: EnvelopeQueuedEvent): Promise<void> {
|
||||||
throttledSetInboxEnvelopeTimestamp(envelope.serverTimestamp);
|
setInboxEnvelopeTimestamp(envelope.serverTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onEnvelopeUnsealed({
|
async function onEnvelopeUnsealed({
|
||||||
envelope,
|
envelope,
|
||||||
}: EnvelopeUnsealedEvent): Promise<void> {
|
}: EnvelopeUnsealedEvent): Promise<void> {
|
||||||
throttledSetInboxEnvelopeTimestamp(envelope.serverTimestamp);
|
setInboxEnvelopeTimestamp(envelope.serverTimestamp);
|
||||||
|
|
||||||
const ourAci = window.textsecure.storage.user.getAci();
|
const ourAci = window.textsecure.storage.user.getAci();
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue