diff --git a/js/modules/emojis.js b/js/modules/emojis.js deleted file mode 100644 index e2d13cc1f07..00000000000 --- a/js/modules/emojis.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019-2020 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only - -const { take } = require('lodash'); -const { getRecentEmojis } = require('../../ts/sql/Client').default; - -module.exports = { - getInitialState, - load, -}; - -let initialState = null; - -async function load() { - const recents = await getRecentEmojisForRedux(); - - initialState = { - recents: take(recents, 32), - }; -} - -async function getRecentEmojisForRedux() { - const recent = await getRecentEmojis(); - return recent.map(e => e.shortName); -} - -function getInitialState() { - return initialState; -} diff --git a/js/modules/signal.js b/js/modules/signal.js index 5ae22b8b162..bd791f1bf74 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -10,7 +10,6 @@ const { start: conversationControllerStart, } = require('../../ts/ConversationController'); const Data = require('../../ts/sql/Client').default; -const Emojis = require('./emojis'); const EmojiLib = require('../../ts/components/emoji/lib'); const Groups = require('../../ts/groups'); const GroupChange = require('../../ts/groupChange'); @@ -454,7 +453,6 @@ exports.setup = (options = {}) => { Curve, conversationControllerStart, Data, - Emojis, EmojiLib, Groups, GroupChange, diff --git a/ts/background.ts b/ts/background.ts index a33b24924ad..3b3538785eb 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -98,6 +98,10 @@ import { themeChanged } from './shims/themeChanged'; import { createIPCEvents } from './util/createIPCEvents'; import { RemoveAllConfiguration } from './types/RemoveAllConfiguration'; import * as log from './logging/log'; +import { + loadRecentEmojis, + getEmojiReducerState, +} from './util/loadRecentEmojis'; const MAX_ATTACHMENT_DOWNLOAD_AGE = 3600 * 72 * 1000; @@ -885,7 +889,7 @@ export async function startApp(): Promise { await Promise.all([ window.ConversationController.load(), Stickers.load(), - window.Signal.Emojis.load(), + loadRecentEmojis(), window.textsecure.storage.protocol.hydrateCaches(), ]); await window.ConversationController.checkForConflicts(); @@ -951,7 +955,7 @@ export async function startApp(): Promise { selectedConversationTitle: '', showArchived: false, }, - emojis: window.Signal.Emojis.getInitialState(), + emojis: getEmojiReducerState(), items: window.storage.getItemsState(), preferredReactions: preferredReactions.getInitialState(), stickers: Stickers.getInitialState(), diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index d430d4dbf32..ed28f0c6faa 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -130,13 +130,6 @@ "updated": "2018-09-19T18:13:29.628Z", "reasonDetail": "Interacting with already-existing DOM nodes" }, - { - "rule": "jQuery-load(", - "path": "js/modules/emojis.js", - "line": "async function load() {", - "reasonCategory": "falseMatch", - "updated": "2019-10-31T17:28:08.684Z" - }, { "rule": "jQuery-$(", "path": "js/views/key_verification_view.js", @@ -14374,4 +14367,4 @@ "reasonCategory": "usageTrusted", "updated": "2021-09-17T21:02:59.414Z" } -] \ No newline at end of file +] diff --git a/ts/util/loadRecentEmojis.ts b/ts/util/loadRecentEmojis.ts new file mode 100644 index 00000000000..5c42c73dedf --- /dev/null +++ b/ts/util/loadRecentEmojis.ts @@ -0,0 +1,28 @@ +// Copyright 2019-2021 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import { take } from 'lodash'; +import dataInterface from '../sql/Client'; + +type RecentEmojiObjectType = { + recents: Array; +}; + +let initialState: RecentEmojiObjectType; + +async function getRecentEmojisForRedux() { + const recent = await dataInterface.getRecentEmojis(); + return recent.map(e => e.shortName); +} + +export async function loadRecentEmojis(): Promise { + const recents = await getRecentEmojisForRedux(); + + initialState = { + recents: take(recents, 32), + }; +} + +export function getEmojiReducerState(): RecentEmojiObjectType { + return initialState; +}