Skip to content

Commit

Permalink
Notification improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Sep 27, 2021
1 parent baf445c commit 826306a
Show file tree
Hide file tree
Showing 16 changed files with 416 additions and 410 deletions.
4 changes: 0 additions & 4 deletions js/modules/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const EmojiLib = require('../../ts/components/emoji/lib');
const Groups = require('../../ts/groups');
const GroupChange = require('../../ts/groupChange');
const IndexedDB = require('./indexeddb');
const Notifications = require('../../ts/notifications');
const OS = require('../../ts/OS');
const Stickers = require('../../ts/types/Stickers');
const Settings = require('./settings');
Expand Down Expand Up @@ -159,7 +158,6 @@ const {
const {
initializeUpdateListener,
} = require('../../ts/services/updateListener');
const { notify } = require('../../ts/services/notify');
const { calling } = require('../../ts/services/calling');
const { onTimeout, removeTimeout } = require('../../ts/services/timers');
const {
Expand Down Expand Up @@ -406,7 +404,6 @@ exports.setup = (options = {}) => {
initializeNetworkObserver,
initializeUpdateListener,
onTimeout,
notify,
removeTimeout,
runStorageServiceSyncJob,
storageServiceUploadJob,
Expand Down Expand Up @@ -454,7 +451,6 @@ exports.setup = (options = {}) => {
GroupChange,
IndexedDB,
Migrations,
Notifications,
OS,
RemoteConfig,
Settings,
Expand Down
251 changes: 0 additions & 251 deletions js/notifications.js

This file was deleted.

19 changes: 11 additions & 8 deletions ts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { updateConversationsWithUuidLookup } from './updateConversationsWithUuid
import { initializeAllJobQueues } from './jobs/initializeAllJobQueues';
import { removeStorageKeyJobQueue } from './jobs/removeStorageKeyJobQueue';
import { ourProfileKeyService } from './services/ourProfileKey';
import { notificationService } from './services/notifications';
import { shouldRespondWithProfileKey } from './util/shouldRespondWithProfileKey';
import { LatestQueue } from './util/LatestQueue';
import { parseIntOrThrow } from './util/parseIntOrThrow';
Expand Down Expand Up @@ -134,6 +135,10 @@ export async function startApp(): Promise<void> {
window.Signal.Util.MessageController.install();
window.Signal.conversationControllerStart();
window.startupProcessingQueue = new window.Signal.Util.StartupQueue();
notificationService.initialize({
i18n: window.i18n,
storage: window.storage,
});
window.attachmentDownloadQueue = [];
try {
log.info('Initializing SQL in renderer');
Expand Down Expand Up @@ -1777,12 +1782,10 @@ export async function startApp(): Promise<void> {
}
});

window.registerForActive(() => window.Whisper.Notifications.clear());
window.addEventListener('unload', () =>
window.Whisper.Notifications.fastClear()
);
window.registerForActive(() => notificationService.clear());
window.addEventListener('unload', () => notificationService.fastClear());

window.Whisper.Notifications.on('click', (id, messageId) => {
notificationService.on('click', (id, messageId) => {
window.showWindow();
if (id) {
window.Whisper.events.trigger('showConversation', id, messageId);
Expand Down Expand Up @@ -2071,7 +2074,7 @@ export async function startApp(): Promise<void> {
profileKeyResponseQueue.pause();
lightSessionResetQueue.pause();
window.Whisper.deliveryReceiptQueue.pause();
window.Whisper.Notifications.disable();
notificationService.disable();

window.Signal.Services.initializeGroupCredentialFetcher();

Expand Down Expand Up @@ -2323,7 +2326,7 @@ export async function startApp(): Promise<void> {
profileKeyResponseQueue.start();
lightSessionResetQueue.start();
window.Whisper.deliveryReceiptQueue.start();
window.Whisper.Notifications.enable();
notificationService.enable();

await onAppView;

Expand Down Expand Up @@ -2387,7 +2390,7 @@ export async function startApp(): Promise<void> {
profileKeyResponseQueue.pause();
lightSessionResetQueue.pause();
window.Whisper.deliveryReceiptQueue.pause();
window.Whisper.Notifications.disable();
notificationService.disable();
}

let initialStartupCount = 0;
Expand Down
7 changes: 4 additions & 3 deletions ts/messageModifiers/ReadSyncs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2020 Signal Messenger, LLC
// Copyright 2017-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

/* eslint-disable max-classes-per-file */
Expand All @@ -8,6 +8,7 @@ import { Collection, Model } from 'backbone';
import { MessageModel } from '../models/messages';
import { isIncoming } from '../state/selectors/message';
import { isMessageUnread } from '../util/isMessageUnread';
import { notificationService } from '../services/notifications';
import * as log from '../logging/log';

type ReadSyncAttributesType = {
Expand Down Expand Up @@ -39,7 +40,7 @@ async function maybeItIsAReactionReadSync(sync: ReadSyncModel): Promise<void> {
return;
}

window.Whisper.Notifications.removeBy({
notificationService.removeBy({
conversationId: readReaction.conversationId,
emoji: readReaction.emoji,
targetAuthorUuid: readReaction.targetAuthorUuid,
Expand Down Expand Up @@ -99,7 +100,7 @@ export class ReadSyncs extends Collection {
return;
}

window.Whisper.Notifications.removeBy({ messageId: found.id });
notificationService.removeBy({ messageId: found.id });

const message = window.MessageController.register(found.id, found);
const readAt = Math.min(sync.get('readAt'), Date.now());
Expand Down
3 changes: 2 additions & 1 deletion ts/messageModifiers/ViewSyncs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MessageModel } from '../models/messages';
import { ReadStatus } from '../messages/MessageReadStatus';
import { markViewed } from '../services/MessageUpdater';
import { isIncoming } from '../state/selectors/message';
import { notificationService } from '../services/notifications';
import * as log from '../logging/log';

type ViewSyncAttributesType = {
Expand Down Expand Up @@ -83,7 +84,7 @@ export class ViewSyncs extends Collection {
return;
}

window.Whisper.Notifications.removeBy({ messageId: found.id });
notificationService.removeBy({ messageId: found.id });

const message = window.MessageController.register(found.id, found);

Expand Down

0 comments on commit 826306a

Please sign in to comment.