Do not generate notification when disabled

Generating identicons for notifications is costly even if they are
cached. Avoid this extra load when notifications are not going to be
shown anyway.
This commit is contained in:
Fedor Indutny 2021-04-09 08:52:31 -07:00 committed by Josh Perez
parent 23b3d34eef
commit 847cc3e055
2 changed files with 7 additions and 0 deletions

View File

@ -5066,6 +5066,12 @@ export class ConversationModel extends window.Backbone.Model<
}
async notify(message: WhatIsThis, reaction?: WhatIsThis): Promise<void> {
// As a performance optimization don't perform any work if notifications are
// disabled.
if (!window.Whisper.Notifications.isEnabled) {
return;
}
if (this.isMuted()) {
return;
}

1
ts/window.d.ts vendored
View File

@ -708,6 +708,7 @@ export type WhisperType = {
BodyRangeType: BodyRangeType;
Notifications: {
isEnabled: boolean;
removeBy: (filter: Partial<unknown>) => void;
add: (notification: unknown) => void;
clear: () => void;