Pre-alpha: React with any emoji, behind flag
This commit is contained in:
parent
d13c3d3350
commit
0865a5481c
31 changed files with 572 additions and 234 deletions
|
@ -1,6 +1,7 @@
|
|||
import { take, uniq } from 'lodash';
|
||||
import { EmojiPickDataType } from '../../components/emoji/EmojiPicker';
|
||||
import dataInterface from '../../sql/Client';
|
||||
import { useBoundActions } from '../../util/hooks';
|
||||
|
||||
const { updateEmojiUsage } = dataInterface;
|
||||
|
||||
|
@ -12,32 +13,34 @@ export type EmojisStateType = {
|
|||
|
||||
// Actions
|
||||
|
||||
type UseEmojiPayloadType = string;
|
||||
type UseEmojiAction = {
|
||||
type OnUseEmojiPayloadType = string;
|
||||
type OnUseEmojiAction = {
|
||||
type: 'emojis/USE_EMOJI';
|
||||
payload: Promise<UseEmojiPayloadType>;
|
||||
payload: Promise<OnUseEmojiPayloadType>;
|
||||
};
|
||||
type UseEmojiFulfilledAction = {
|
||||
type OnUseEmojiFulfilledAction = {
|
||||
type: 'emojis/USE_EMOJI_FULFILLED';
|
||||
payload: UseEmojiPayloadType;
|
||||
payload: OnUseEmojiPayloadType;
|
||||
};
|
||||
|
||||
export type EmojisActionType = UseEmojiAction | UseEmojiFulfilledAction;
|
||||
export type EmojisActionType = OnUseEmojiAction | OnUseEmojiFulfilledAction;
|
||||
|
||||
// Action Creators
|
||||
|
||||
export const actions = {
|
||||
useEmoji,
|
||||
onUseEmoji,
|
||||
};
|
||||
|
||||
function useEmoji({ shortName }: EmojiPickDataType): UseEmojiAction {
|
||||
export const useActions = () => useBoundActions(actions);
|
||||
|
||||
function onUseEmoji({ shortName }: EmojiPickDataType): OnUseEmojiAction {
|
||||
return {
|
||||
type: 'emojis/USE_EMOJI',
|
||||
payload: doUseEmoji(shortName),
|
||||
};
|
||||
}
|
||||
|
||||
async function doUseEmoji(shortName: string): Promise<UseEmojiPayloadType> {
|
||||
async function doUseEmoji(shortName: string): Promise<OnUseEmojiPayloadType> {
|
||||
await updateEmojiUsage(shortName);
|
||||
|
||||
return shortName;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue