diff --git a/js/expiring_messages.js b/js/expiring_messages.js index fb181937abe0..2d5b135512f2 100644 --- a/js/expiring_messages.js +++ b/js/expiring_messages.js @@ -39,12 +39,6 @@ sentAt: message.get('sent_at'), }); - Whisper.events.trigger( - 'messageExpired', - message.id, - message.conversationId - ); - const conversation = message.getConversation(); if (conversation) { conversation.trigger('expired', message); diff --git a/js/modules/signal.js b/js/modules/signal.js index d09a212f9713..02a0b8d3e560 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -3,7 +3,6 @@ // The idea with this file is to make it webpackable for the style guide -const { bindActionCreators } = require('redux'); const Backbone = require('../../ts/backbone'); const Crypto = require('../../ts/Crypto'); const Curve = require('../../ts/Curve'); @@ -416,7 +415,6 @@ exports.setup = (options = {}) => { }; const State = { - bindActionCreators, createStore, Roots, Ducks, diff --git a/ts/background.ts b/ts/background.ts index f1e924aa9762..466984e56f70 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-only import { isNumber } from 'lodash'; +import { bindActionCreators } from 'redux'; import { render } from 'react-dom'; import { DecryptionErrorMessage, @@ -42,6 +43,7 @@ import * as universalExpireTimer from './util/universalExpireTimer'; import { isDirectConversation, isGroupV2 } from './util/whatTypeOfConversation'; import { getSendOptions } from './util/getSendOptions'; import { BackOff } from './util/BackOff'; +import { actionCreators } from './state/actions'; const MAX_ATTACHMENT_DOWNLOAD_AGE = 3600 * 72 * 1000; @@ -951,68 +953,48 @@ export async function startApp(): Promise { const store = window.Signal.State.createStore(initialState); window.reduxStore = store; - const actions: WhatIsThis = {}; - window.reduxActions = actions; - // Binding these actions to our redux store and exposing them allows us to update // redux when things change in the backbone world. - actions.app = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.app.actions, - store.dispatch - ); - actions.calling = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.calling.actions, - store.dispatch - ); - actions.conversations = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.conversations.actions, - store.dispatch - ); - actions.emojis = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.emojis.actions, - store.dispatch - ); - actions.expiration = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.expiration.actions, - store.dispatch - ); - actions.items = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.items.actions, - store.dispatch - ); - actions.linkPreviews = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.linkPreviews.actions, - store.dispatch - ); - actions.network = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.network.actions, - store.dispatch - ); - actions.updates = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.updates.actions, - store.dispatch - ); - actions.user = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.user.actions, - store.dispatch - ); - actions.search = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.search.actions, - store.dispatch - ); - actions.stickers = window.Signal.State.bindActionCreators( - window.Signal.State.Ducks.stickers.actions, - store.dispatch - ); + window.reduxActions = { + app: bindActionCreators(actionCreators.app, store.dispatch), + audioPlayer: bindActionCreators( + actionCreators.audioPlayer, + store.dispatch + ), + calling: bindActionCreators(actionCreators.calling, store.dispatch), + conversations: bindActionCreators( + actionCreators.conversations, + store.dispatch + ), + emojis: bindActionCreators(actionCreators.emojis, store.dispatch), + expiration: bindActionCreators(actionCreators.expiration, store.dispatch), + globalModals: bindActionCreators( + actionCreators.globalModals, + store.dispatch + ), + items: bindActionCreators(actionCreators.items, store.dispatch), + linkPreviews: bindActionCreators( + actionCreators.linkPreviews, + store.dispatch + ), + network: bindActionCreators(actionCreators.network, store.dispatch), + safetyNumber: bindActionCreators( + actionCreators.safetyNumber, + store.dispatch + ), + search: bindActionCreators(actionCreators.search, store.dispatch), + stickers: bindActionCreators(actionCreators.stickers, store.dispatch), + updates: bindActionCreators(actionCreators.updates, store.dispatch), + user: bindActionCreators(actionCreators.user, store.dispatch), + }; const { conversationAdded, conversationChanged, conversationRemoved, removeAllConversations, - messageExpired, - } = actions.conversations; - const { userChanged } = actions.user; + } = window.reduxActions.conversations; + const { userChanged } = window.reduxActions.user; convoCollection.on('remove', conversation => { const { id } = conversation || {}; @@ -1056,7 +1038,6 @@ export async function startApp(): Promise { }); convoCollection.on('reset', removeAllConversations); - window.Whisper.events.on('messageExpired', messageExpired); window.Whisper.events.on('userChanged', userChanged); let shortcutGuideView: WhatIsThis | null = null; diff --git a/ts/state/actions.ts b/ts/state/actions.ts index 6aa89b5f9374..7a915ab41a76 100644 --- a/ts/state/actions.ts +++ b/ts/state/actions.ts @@ -16,6 +16,25 @@ import { actions as search } from './ducks/search'; import { actions as stickers } from './ducks/stickers'; import { actions as updates } from './ducks/updates'; import { actions as user } from './ducks/user'; +import { ReduxActions } from './types'; + +export const actionCreators: ReduxActions = { + app, + audioPlayer, + calling, + conversations, + emojis, + expiration, + globalModals, + items, + linkPreviews, + network, + safetyNumber, + search, + stickers, + updates, + user, +}; export const mapDispatchToProps = { ...app, diff --git a/ts/window.d.ts b/ts/window.d.ts index d485bc0641a1..ba806e73ad4a 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -8,7 +8,6 @@ import * as Underscore from 'underscore'; import moment from 'moment'; import PQueue from 'p-queue/dist'; import { Ref } from 'react'; -import { bindActionCreators } from 'redux'; import { imageToBlurHash } from './util/imageToBlurHash'; import * as LinkPreviews from '../js/modules/link_previews.d'; import * as Util from './util'; @@ -484,7 +483,6 @@ declare global { }; Views: WhatIsThis; State: { - bindActionCreators: typeof bindActionCreators; createStore: typeof createStore; Roots: { createApp: typeof createApp;