Adds message forwarding
This commit is contained in:
parent
cd489a35fd
commit
d203f125c6
42 changed files with 1638 additions and 139 deletions
77
ts/state/ducks/linkPreviews.ts
Normal file
77
ts/state/ducks/linkPreviews.ts
Normal file
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { LinkPreviewType } from '../../types/message/LinkPreviews';
|
||||
|
||||
// State
|
||||
|
||||
export type LinkPreviewsStateType = {
|
||||
readonly linkPreview?: LinkPreviewType;
|
||||
};
|
||||
|
||||
// Actions
|
||||
|
||||
const ADD_PREVIEW = 'linkPreviews/ADD_PREVIEW';
|
||||
const REMOVE_PREVIEW = 'linkPreviews/REMOVE_PREVIEW';
|
||||
|
||||
type AddLinkPreviewActionType = {
|
||||
type: 'linkPreviews/ADD_PREVIEW';
|
||||
payload: LinkPreviewType;
|
||||
};
|
||||
|
||||
type RemoveLinkPreviewActionType = {
|
||||
type: 'linkPreviews/REMOVE_PREVIEW';
|
||||
};
|
||||
|
||||
type LinkPreviewsActionType =
|
||||
| AddLinkPreviewActionType
|
||||
| RemoveLinkPreviewActionType;
|
||||
|
||||
// Action Creators
|
||||
|
||||
export const actions = {
|
||||
addLinkPreview,
|
||||
removeLinkPreview,
|
||||
};
|
||||
|
||||
function addLinkPreview(payload: LinkPreviewType): AddLinkPreviewActionType {
|
||||
return {
|
||||
type: ADD_PREVIEW,
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
function removeLinkPreview(): RemoveLinkPreviewActionType {
|
||||
return {
|
||||
type: REMOVE_PREVIEW,
|
||||
};
|
||||
}
|
||||
|
||||
// Reducer
|
||||
|
||||
export function getEmptyState(): LinkPreviewsStateType {
|
||||
return {
|
||||
linkPreview: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function reducer(
|
||||
state: Readonly<LinkPreviewsStateType> = getEmptyState(),
|
||||
action: Readonly<LinkPreviewsActionType>
|
||||
): LinkPreviewsStateType {
|
||||
if (action.type === ADD_PREVIEW) {
|
||||
const { payload } = action;
|
||||
|
||||
return {
|
||||
linkPreview: payload,
|
||||
};
|
||||
}
|
||||
|
||||
if (action.type === REMOVE_PREVIEW) {
|
||||
return {
|
||||
linkPreview: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue