signal-desktop/ts/util/loadRecentEmojis.ts

29 lines
665 B
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2019 Signal Messenger, LLC
2021-09-20 17:59:09 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import { take } from 'lodash';
2024-07-22 18:16:33 +00:00
import { DataReader } from '../sql/Client';
2021-09-20 17:59:09 +00:00
export type RecentEmojiObjectType = {
2021-09-20 17:59:09 +00:00
recents: Array<string>;
};
let initialState: RecentEmojiObjectType;
async function getRecentEmojisForRedux() {
2024-07-22 18:16:33 +00:00
const recent = await DataReader.getRecentEmojis();
2021-09-20 17:59:09 +00:00
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;
}