Move emoji loading into TS

This commit is contained in:
Josh Perez 2021-09-20 13:59:09 -04:00 committed by GitHub
parent 48daaaa81d
commit e9ef239ff0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 41 deletions

View file

@ -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;
}

View file

@ -10,7 +10,6 @@ const {
start: conversationControllerStart, start: conversationControllerStart,
} = require('../../ts/ConversationController'); } = require('../../ts/ConversationController');
const Data = require('../../ts/sql/Client').default; const Data = require('../../ts/sql/Client').default;
const Emojis = require('./emojis');
const EmojiLib = require('../../ts/components/emoji/lib'); const EmojiLib = require('../../ts/components/emoji/lib');
const Groups = require('../../ts/groups'); const Groups = require('../../ts/groups');
const GroupChange = require('../../ts/groupChange'); const GroupChange = require('../../ts/groupChange');
@ -454,7 +453,6 @@ exports.setup = (options = {}) => {
Curve, Curve,
conversationControllerStart, conversationControllerStart,
Data, Data,
Emojis,
EmojiLib, EmojiLib,
Groups, Groups,
GroupChange, GroupChange,

View file

@ -98,6 +98,10 @@ import { themeChanged } from './shims/themeChanged';
import { createIPCEvents } from './util/createIPCEvents'; import { createIPCEvents } from './util/createIPCEvents';
import { RemoveAllConfiguration } from './types/RemoveAllConfiguration'; import { RemoveAllConfiguration } from './types/RemoveAllConfiguration';
import * as log from './logging/log'; import * as log from './logging/log';
import {
loadRecentEmojis,
getEmojiReducerState,
} from './util/loadRecentEmojis';
const MAX_ATTACHMENT_DOWNLOAD_AGE = 3600 * 72 * 1000; const MAX_ATTACHMENT_DOWNLOAD_AGE = 3600 * 72 * 1000;
@ -885,7 +889,7 @@ export async function startApp(): Promise<void> {
await Promise.all([ await Promise.all([
window.ConversationController.load(), window.ConversationController.load(),
Stickers.load(), Stickers.load(),
window.Signal.Emojis.load(), loadRecentEmojis(),
window.textsecure.storage.protocol.hydrateCaches(), window.textsecure.storage.protocol.hydrateCaches(),
]); ]);
await window.ConversationController.checkForConflicts(); await window.ConversationController.checkForConflicts();
@ -951,7 +955,7 @@ export async function startApp(): Promise<void> {
selectedConversationTitle: '', selectedConversationTitle: '',
showArchived: false, showArchived: false,
}, },
emojis: window.Signal.Emojis.getInitialState(), emojis: getEmojiReducerState(),
items: window.storage.getItemsState(), items: window.storage.getItemsState(),
preferredReactions: preferredReactions.getInitialState(), preferredReactions: preferredReactions.getInitialState(),
stickers: Stickers.getInitialState(), stickers: Stickers.getInitialState(),

View file

@ -130,13 +130,6 @@
"updated": "2018-09-19T18:13:29.628Z", "updated": "2018-09-19T18:13:29.628Z",
"reasonDetail": "Interacting with already-existing DOM nodes" "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-$(", "rule": "jQuery-$(",
"path": "js/views/key_verification_view.js", "path": "js/views/key_verification_view.js",
@ -14374,4 +14367,4 @@
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2021-09-17T21:02:59.414Z" "updated": "2021-09-17T21:02:59.414Z"
} }
] ]

View file

@ -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<string>;
};
let initialState: RecentEmojiObjectType;
async function getRecentEmojisForRedux() {
const recent = await dataInterface.getRecentEmojis();
return recent.map(e => e.shortName);
}
export async function loadRecentEmojis(): Promise<void> {
const recents = await getRecentEmojisForRedux();
initialState = {
recents: take(recents, 32),
};
}
export function getEmojiReducerState(): RecentEmojiObjectType {
return initialState;
}