2020-10-30 15:34:04 -05:00
|
|
|
// Copyright 2019-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-05-24 16:58:27 -07:00
|
|
|
const { take } = require('lodash');
|
2020-04-01 11:59:11 -07:00
|
|
|
const { getRecentEmojis } = require('../../ts/sql/Client').default;
|
2019-05-24 16:58:27 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|