Move emoji loading into TS
This commit is contained in:
parent
48daaaa81d
commit
e9ef239ff0
5 changed files with 35 additions and 41 deletions
|
@ -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;
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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<void> {
|
|||
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<void> {
|
|||
selectedConversationTitle: '',
|
||||
showArchived: false,
|
||||
},
|
||||
emojis: window.Signal.Emojis.getInitialState(),
|
||||
emojis: getEmojiReducerState(),
|
||||
items: window.storage.getItemsState(),
|
||||
preferredReactions: preferredReactions.getInitialState(),
|
||||
stickers: Stickers.getInitialState(),
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
28
ts/util/loadRecentEmojis.ts
Normal file
28
ts/util/loadRecentEmojis.ts
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue