2021-05-28 16:15:17 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-07-01 00:52:03 +00:00
|
|
|
import type { ThunkAction } from 'redux-thunk';
|
2023-01-13 20:07:26 +00:00
|
|
|
import type { ReadonlyDeep } from 'type-fest';
|
2022-08-16 23:59:11 +00:00
|
|
|
import type { ExplodePromiseResultType } from '../../util/explodePromise';
|
2022-12-08 06:41:37 +00:00
|
|
|
import type { GroupV2PendingMemberType } from '../../model-types.d';
|
2022-07-01 00:52:03 +00:00
|
|
|
import type { PropsForMessage } from '../selectors/message';
|
2022-12-08 06:41:37 +00:00
|
|
|
import type { RecipientsByConversation } from './stories';
|
2022-08-16 23:59:11 +00:00
|
|
|
import type { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';
|
|
|
|
import type { StateType as RootStateType } from '../reducer';
|
|
|
|
import type { UUIDStringType } from '../../types/UUID';
|
|
|
|
import * as SingleServePromise from '../../services/singleServePromise';
|
2022-12-09 19:01:46 +00:00
|
|
|
import * as Stickers from '../../types/Stickers';
|
2023-02-27 22:34:43 +00:00
|
|
|
import * as Errors from '../../types/errors';
|
2022-07-01 00:52:03 +00:00
|
|
|
import { getMessageById } from '../../messages/getMessageById';
|
|
|
|
import { getMessagePropsSelector } from '../selectors/message';
|
2022-12-09 17:35:34 +00:00
|
|
|
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
|
2022-12-08 06:41:37 +00:00
|
|
|
import { longRunningTaskWrapper } from '../../util/longRunningTaskWrapper';
|
2022-07-01 00:52:03 +00:00
|
|
|
import { useBoundActions } from '../../hooks/useBoundActions';
|
2022-12-08 06:41:37 +00:00
|
|
|
import { isGroupV1 } from '../../util/whatTypeOfConversation';
|
2023-02-27 22:34:43 +00:00
|
|
|
import { authorizeArtCreator } from '../../textsecure/authorizeArtCreator';
|
|
|
|
import type { AuthorizeArtCreatorOptionsType } from '../../textsecure/authorizeArtCreator';
|
2022-12-08 06:41:37 +00:00
|
|
|
import { getGroupMigrationMembers } from '../../groups';
|
2023-02-27 22:34:43 +00:00
|
|
|
import * as log from '../../logging/log';
|
|
|
|
import { ToastType } from '../../types/Toast';
|
|
|
|
import { SHOW_TOAST } from './toast';
|
|
|
|
import type { ShowToastActionType } from './toast';
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
// State
|
|
|
|
|
2023-03-24 21:16:48 +00:00
|
|
|
export type ConfirmDeleteForMeModalProps = ReadonlyDeep<{
|
|
|
|
count: number;
|
|
|
|
}>;
|
2023-01-13 20:07:26 +00:00
|
|
|
export type ForwardMessagePropsType = ReadonlyDeep<
|
|
|
|
Omit<PropsForMessage, 'renderingContext' | 'menu' | 'contextMenu'>
|
2022-11-04 13:22:07 +00:00
|
|
|
>;
|
2023-03-20 22:23:53 +00:00
|
|
|
export type ForwardMessagesPropsType = ReadonlyDeep<{
|
|
|
|
messages: Array<ForwardMessagePropsType>;
|
|
|
|
onForward?: () => void;
|
|
|
|
}>;
|
2023-01-13 20:07:26 +00:00
|
|
|
export type SafetyNumberChangedBlockingDataType = ReadonlyDeep<{
|
2022-09-26 16:24:52 +00:00
|
|
|
promiseUuid: UUIDStringType;
|
|
|
|
source?: SafetyNumberChangeSource;
|
|
|
|
}>;
|
2023-02-27 22:34:43 +00:00
|
|
|
export type AuthorizeArtCreatorDataType =
|
|
|
|
ReadonlyDeep<AuthorizeArtCreatorOptionsType>;
|
2022-09-26 16:24:52 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type MigrateToGV2PropsType = ReadonlyDeep<{
|
2022-12-08 06:41:37 +00:00
|
|
|
areWeInvited: boolean;
|
|
|
|
conversationId: string;
|
2023-01-13 20:07:26 +00:00
|
|
|
droppedMemberIds: Array<string>;
|
2022-12-08 06:41:37 +00:00
|
|
|
hasMigrated: boolean;
|
2023-01-13 20:07:26 +00:00
|
|
|
invitedMemberIds: Array<string>;
|
|
|
|
}>;
|
2022-12-08 06:41:37 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type GlobalModalsStateType = ReadonlyDeep<{
|
2022-12-08 06:41:37 +00:00
|
|
|
addUserToAnotherGroupModalContactId?: string;
|
2022-09-26 16:24:52 +00:00
|
|
|
contactModalState?: ContactModalStateType;
|
2022-12-22 03:07:45 +00:00
|
|
|
errorModalProps?: {
|
|
|
|
description?: string;
|
|
|
|
title?: string;
|
|
|
|
};
|
2023-03-20 22:23:53 +00:00
|
|
|
forwardMessagesProps?: ForwardMessagesPropsType;
|
2022-12-08 06:41:37 +00:00
|
|
|
gv2MigrationProps?: MigrateToGV2PropsType;
|
2023-03-24 21:16:48 +00:00
|
|
|
hasConfirmationModal: boolean;
|
2022-09-26 16:24:52 +00:00
|
|
|
isProfileEditorVisible: boolean;
|
|
|
|
isSignalConnectionsVisible: boolean;
|
2022-12-22 03:07:45 +00:00
|
|
|
isShortcutGuideModalVisible: boolean;
|
2022-09-26 16:24:52 +00:00
|
|
|
isStoriesSettingsVisible: boolean;
|
|
|
|
isWhatsNewVisible: boolean;
|
|
|
|
profileEditorHasError: boolean;
|
|
|
|
safetyNumberChangedBlockingData?: SafetyNumberChangedBlockingDataType;
|
|
|
|
safetyNumberModalContactId?: string;
|
2022-12-09 19:01:46 +00:00
|
|
|
stickerPackPreviewId?: string;
|
2023-02-27 22:34:43 +00:00
|
|
|
isAuthorizingArtCreator?: boolean;
|
|
|
|
authArtCreatorData?: AuthorizeArtCreatorDataType;
|
2022-09-26 16:24:52 +00:00
|
|
|
userNotFoundModalState?: UserNotFoundModalStateType;
|
|
|
|
}>;
|
2021-05-28 16:15:17 +00:00
|
|
|
|
|
|
|
// Actions
|
|
|
|
|
2021-09-21 22:37:10 +00:00
|
|
|
const HIDE_CONTACT_MODAL = 'globalModals/HIDE_CONTACT_MODAL';
|
|
|
|
const SHOW_CONTACT_MODAL = 'globalModals/SHOW_CONTACT_MODAL';
|
2022-07-01 00:52:03 +00:00
|
|
|
const HIDE_WHATS_NEW_MODAL = 'globalModals/HIDE_WHATS_NEW_MODAL_MODAL';
|
2021-10-23 00:41:45 +00:00
|
|
|
const SHOW_WHATS_NEW_MODAL = 'globalModals/SHOW_WHATS_NEW_MODAL_MODAL';
|
2022-04-05 00:38:22 +00:00
|
|
|
const HIDE_UUID_NOT_FOUND_MODAL = 'globalModals/HIDE_UUID_NOT_FOUND_MODAL';
|
2022-07-01 00:52:03 +00:00
|
|
|
const SHOW_UUID_NOT_FOUND_MODAL = 'globalModals/SHOW_UUID_NOT_FOUND_MODAL';
|
2022-07-21 00:07:09 +00:00
|
|
|
const SHOW_STORIES_SETTINGS = 'globalModals/SHOW_STORIES_SETTINGS';
|
|
|
|
const HIDE_STORIES_SETTINGS = 'globalModals/HIDE_STORIES_SETTINGS';
|
2023-03-20 22:23:53 +00:00
|
|
|
const TOGGLE_FORWARD_MESSAGES_MODAL =
|
|
|
|
'globalModals/TOGGLE_FORWARD_MESSAGES_MODAL';
|
2021-07-19 19:26:06 +00:00
|
|
|
const TOGGLE_PROFILE_EDITOR = 'globalModals/TOGGLE_PROFILE_EDITOR';
|
|
|
|
export const TOGGLE_PROFILE_EDITOR_ERROR =
|
|
|
|
'globalModals/TOGGLE_PROFILE_EDITOR_ERROR';
|
2021-10-06 20:27:14 +00:00
|
|
|
const TOGGLE_SAFETY_NUMBER_MODAL = 'globalModals/TOGGLE_SAFETY_NUMBER_MODAL';
|
2022-09-26 16:24:52 +00:00
|
|
|
const TOGGLE_ADD_USER_TO_ANOTHER_GROUP_MODAL =
|
|
|
|
'globalModals/TOGGLE_ADD_USER_TO_ANOTHER_GROUP_MODAL';
|
2022-07-21 00:07:09 +00:00
|
|
|
const TOGGLE_SIGNAL_CONNECTIONS_MODAL =
|
|
|
|
'globalModals/TOGGLE_SIGNAL_CONNECTIONS_MODAL';
|
2022-08-16 23:59:11 +00:00
|
|
|
export const SHOW_SEND_ANYWAY_DIALOG = 'globalModals/SHOW_SEND_ANYWAY_DIALOG';
|
|
|
|
const HIDE_SEND_ANYWAY_DIALOG = 'globalModals/HIDE_SEND_ANYWAY_DIALOG';
|
2022-12-08 06:41:37 +00:00
|
|
|
const SHOW_GV2_MIGRATION_DIALOG = 'globalModals/SHOW_GV2_MIGRATION_DIALOG';
|
|
|
|
const CLOSE_GV2_MIGRATION_DIALOG = 'globalModals/CLOSE_GV2_MIGRATION_DIALOG';
|
2022-12-09 19:01:46 +00:00
|
|
|
const SHOW_STICKER_PACK_PREVIEW = 'globalModals/SHOW_STICKER_PACK_PREVIEW';
|
|
|
|
const CLOSE_STICKER_PACK_PREVIEW = 'globalModals/CLOSE_STICKER_PACK_PREVIEW';
|
2022-12-22 03:07:45 +00:00
|
|
|
const CLOSE_ERROR_MODAL = 'globalModals/CLOSE_ERROR_MODAL';
|
|
|
|
const SHOW_ERROR_MODAL = 'globalModals/SHOW_ERROR_MODAL';
|
|
|
|
const CLOSE_SHORTCUT_GUIDE_MODAL = 'globalModals/CLOSE_SHORTCUT_GUIDE_MODAL';
|
|
|
|
const SHOW_SHORTCUT_GUIDE_MODAL = 'globalModals/SHOW_SHORTCUT_GUIDE_MODAL';
|
2023-02-27 22:34:43 +00:00
|
|
|
const SHOW_AUTH_ART_CREATOR = 'globalModals/SHOW_AUTH_ART_CREATOR';
|
2023-03-24 21:16:48 +00:00
|
|
|
const TOGGLE_CONFIRMATION_MODAL = 'globalModals/TOGGLE_CONFIRMATION_MODAL';
|
2023-02-27 22:34:43 +00:00
|
|
|
const CANCEL_AUTH_ART_CREATOR = 'globalModals/CANCEL_AUTH_ART_CREATOR';
|
|
|
|
const CONFIRM_AUTH_ART_CREATOR_PENDING =
|
|
|
|
'globalModals/CONFIRM_AUTH_ART_CREATOR_PENDING';
|
|
|
|
const CONFIRM_AUTH_ART_CREATOR_FULFILLED =
|
|
|
|
'globalModals/CONFIRM_AUTH_ART_CREATOR_FULFILLED';
|
2021-05-28 16:15:17 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type ContactModalStateType = ReadonlyDeep<{
|
2021-09-21 22:37:10 +00:00
|
|
|
contactId: string;
|
|
|
|
conversationId?: string;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-09-21 22:37:10 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type UserNotFoundModalStateType = ReadonlyDeep<
|
2022-04-05 00:38:22 +00:00
|
|
|
| {
|
|
|
|
type: 'phoneNumber';
|
|
|
|
phoneNumber: string;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'username';
|
|
|
|
username: string;
|
2023-01-13 20:07:26 +00:00
|
|
|
}
|
|
|
|
>;
|
2021-11-12 01:17:29 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type HideContactModalActionType = ReadonlyDeep<{
|
2021-09-21 22:37:10 +00:00
|
|
|
type: typeof HIDE_CONTACT_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-09-21 22:37:10 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ShowContactModalActionType = ReadonlyDeep<{
|
2021-09-21 22:37:10 +00:00
|
|
|
type: typeof SHOW_CONTACT_MODAL;
|
|
|
|
payload: ContactModalStateType;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-09-21 22:37:10 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type HideWhatsNewModalActionType = ReadonlyDeep<{
|
2021-10-23 00:41:45 +00:00
|
|
|
type: typeof HIDE_WHATS_NEW_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-10-23 00:41:45 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ShowWhatsNewModalActionType = ReadonlyDeep<{
|
2021-10-23 00:41:45 +00:00
|
|
|
type: typeof SHOW_WHATS_NEW_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-10-23 00:41:45 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type HideUserNotFoundModalActionType = ReadonlyDeep<{
|
2022-04-05 00:38:22 +00:00
|
|
|
type: typeof HIDE_UUID_NOT_FOUND_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-11-12 01:17:29 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type ShowUserNotFoundModalActionType = ReadonlyDeep<{
|
2022-04-05 00:38:22 +00:00
|
|
|
type: typeof SHOW_UUID_NOT_FOUND_MODAL;
|
|
|
|
payload: UserNotFoundModalStateType;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-11-12 01:17:29 +00:00
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
type ToggleForwardMessagesModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_FORWARD_MESSAGES_MODAL;
|
|
|
|
payload: ForwardMessagesPropsType | undefined;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ToggleProfileEditorActionType = ReadonlyDeep<{
|
2021-07-19 19:26:06 +00:00
|
|
|
type: typeof TOGGLE_PROFILE_EDITOR;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-07-19 19:26:06 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type ToggleProfileEditorErrorActionType = ReadonlyDeep<{
|
2021-07-19 19:26:06 +00:00
|
|
|
type: typeof TOGGLE_PROFILE_EDITOR_ERROR;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-07-19 19:26:06 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ToggleSafetyNumberModalActionType = ReadonlyDeep<{
|
2021-10-06 20:27:14 +00:00
|
|
|
type: typeof TOGGLE_SAFETY_NUMBER_MODAL;
|
|
|
|
payload: string | undefined;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-10-06 20:27:14 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ToggleAddUserToAnotherGroupModalActionType = ReadonlyDeep<{
|
2022-09-26 16:24:52 +00:00
|
|
|
type: typeof TOGGLE_ADD_USER_TO_ANOTHER_GROUP_MODAL;
|
|
|
|
payload: string | undefined;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-09-26 16:24:52 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ToggleSignalConnectionsModalActionType = ReadonlyDeep<{
|
2022-07-21 00:07:09 +00:00
|
|
|
type: typeof TOGGLE_SIGNAL_CONNECTIONS_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-07-21 00:07:09 +00:00
|
|
|
|
2023-03-24 21:16:48 +00:00
|
|
|
type ToggleConfirmationModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_CONFIRMATION_MODAL;
|
|
|
|
payload: boolean;
|
|
|
|
}>;
|
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ShowStoriesSettingsActionType = ReadonlyDeep<{
|
2022-07-21 00:07:09 +00:00
|
|
|
type: typeof SHOW_STORIES_SETTINGS;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-07-21 00:07:09 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type HideStoriesSettingsActionType = ReadonlyDeep<{
|
2022-07-21 00:07:09 +00:00
|
|
|
type: typeof HIDE_STORIES_SETTINGS;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-07-21 00:07:09 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type StartMigrationToGV2ActionType = ReadonlyDeep<{
|
2022-12-08 06:41:37 +00:00
|
|
|
type: typeof SHOW_GV2_MIGRATION_DIALOG;
|
|
|
|
payload: MigrateToGV2PropsType;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-08 06:41:37 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type CloseGV2MigrationDialogActionType = ReadonlyDeep<{
|
2022-12-08 06:41:37 +00:00
|
|
|
type: typeof CLOSE_GV2_MIGRATION_DIALOG;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-08 06:41:37 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type ShowSendAnywayDialogActionType = ReadonlyDeep<{
|
2022-08-16 23:59:11 +00:00
|
|
|
type: typeof SHOW_SEND_ANYWAY_DIALOG;
|
|
|
|
payload: SafetyNumberChangedBlockingDataType & {
|
2022-11-11 04:10:30 +00:00
|
|
|
untrustedByConversation: RecipientsByConversation;
|
2022-08-16 23:59:11 +00:00
|
|
|
};
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-08-16 23:59:11 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type HideSendAnywayDialogActiontype = ReadonlyDeep<{
|
2022-08-16 23:59:11 +00:00
|
|
|
type: typeof HIDE_SEND_ANYWAY_DIALOG;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-08-16 23:59:11 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type ShowStickerPackPreviewActionType = ReadonlyDeep<{
|
2022-12-09 19:01:46 +00:00
|
|
|
type: typeof SHOW_STICKER_PACK_PREVIEW;
|
|
|
|
payload: string;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-09 19:01:46 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type CloseStickerPackPreviewActionType = ReadonlyDeep<{
|
2022-12-09 19:01:46 +00:00
|
|
|
type: typeof CLOSE_STICKER_PACK_PREVIEW;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-09 19:01:46 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type CloseErrorModalActionType = ReadonlyDeep<{
|
2022-12-22 03:07:45 +00:00
|
|
|
type: typeof CLOSE_ERROR_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-22 03:07:45 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ShowErrorModalActionType = ReadonlyDeep<{
|
2022-12-22 03:07:45 +00:00
|
|
|
type: typeof SHOW_ERROR_MODAL;
|
|
|
|
payload: {
|
|
|
|
description?: string;
|
|
|
|
title?: string;
|
|
|
|
};
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-22 03:07:45 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type CloseShortcutGuideModalActionType = ReadonlyDeep<{
|
2022-12-22 03:07:45 +00:00
|
|
|
type: typeof CLOSE_SHORTCUT_GUIDE_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-22 03:07:45 +00:00
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ShowShortcutGuideModalActionType = ReadonlyDeep<{
|
2022-12-22 03:07:45 +00:00
|
|
|
type: typeof SHOW_SHORTCUT_GUIDE_MODAL;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-22 03:07:45 +00:00
|
|
|
|
2023-02-27 22:34:43 +00:00
|
|
|
export type ShowAuthArtCreatorActionType = ReadonlyDeep<{
|
|
|
|
type: typeof SHOW_AUTH_ART_CREATOR;
|
|
|
|
payload: AuthorizeArtCreatorDataType;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
type CancelAuthArtCreatorActionType = ReadonlyDeep<{
|
|
|
|
type: typeof CANCEL_AUTH_ART_CREATOR;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
type ConfirmAuthArtCreatorPendingActionType = ReadonlyDeep<{
|
|
|
|
type: typeof CONFIRM_AUTH_ART_CREATOR_PENDING;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
type ConfirmAuthArtCreatorFulfilledActionType = ReadonlyDeep<{
|
|
|
|
type: typeof CONFIRM_AUTH_ART_CREATOR_FULFILLED;
|
|
|
|
}>;
|
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type GlobalModalsActionType = ReadonlyDeep<
|
2022-12-08 06:41:37 +00:00
|
|
|
| StartMigrationToGV2ActionType
|
|
|
|
| CloseGV2MigrationDialogActionType
|
2021-09-21 22:37:10 +00:00
|
|
|
| HideContactModalActionType
|
|
|
|
| ShowContactModalActionType
|
2021-10-23 00:41:45 +00:00
|
|
|
| HideWhatsNewModalActionType
|
|
|
|
| ShowWhatsNewModalActionType
|
2022-04-05 00:38:22 +00:00
|
|
|
| HideUserNotFoundModalActionType
|
|
|
|
| ShowUserNotFoundModalActionType
|
2022-07-21 00:07:09 +00:00
|
|
|
| HideStoriesSettingsActionType
|
|
|
|
| ShowStoriesSettingsActionType
|
2022-08-16 23:59:11 +00:00
|
|
|
| HideSendAnywayDialogActiontype
|
2022-11-11 04:10:30 +00:00
|
|
|
| ShowSendAnywayDialogActionType
|
2022-12-09 19:01:46 +00:00
|
|
|
| CloseStickerPackPreviewActionType
|
|
|
|
| ShowStickerPackPreviewActionType
|
2022-12-22 03:07:45 +00:00
|
|
|
| CloseErrorModalActionType
|
|
|
|
| ShowErrorModalActionType
|
|
|
|
| CloseShortcutGuideModalActionType
|
|
|
|
| ShowShortcutGuideModalActionType
|
2023-02-27 22:34:43 +00:00
|
|
|
| CancelAuthArtCreatorActionType
|
|
|
|
| ConfirmAuthArtCreatorPendingActionType
|
|
|
|
| ConfirmAuthArtCreatorFulfilledActionType
|
|
|
|
| ShowAuthArtCreatorActionType
|
2023-03-20 22:23:53 +00:00
|
|
|
| ToggleForwardMessagesModalActionType
|
2021-07-19 19:26:06 +00:00
|
|
|
| ToggleProfileEditorActionType
|
2021-10-06 20:27:14 +00:00
|
|
|
| ToggleProfileEditorErrorActionType
|
2022-07-21 00:07:09 +00:00
|
|
|
| ToggleSafetyNumberModalActionType
|
2022-09-26 16:24:52 +00:00
|
|
|
| ToggleAddUserToAnotherGroupModalActionType
|
2023-01-13 20:07:26 +00:00
|
|
|
| ToggleSignalConnectionsModalActionType
|
2023-03-24 21:16:48 +00:00
|
|
|
| ToggleConfirmationModalActionType
|
2023-01-13 20:07:26 +00:00
|
|
|
>;
|
2021-05-28 16:15:17 +00:00
|
|
|
|
|
|
|
// Action Creators
|
|
|
|
|
|
|
|
export const actions = {
|
2021-09-21 22:37:10 +00:00
|
|
|
hideContactModal,
|
|
|
|
showContactModal,
|
2021-10-23 00:41:45 +00:00
|
|
|
hideWhatsNewModal,
|
|
|
|
showWhatsNewModal,
|
2022-04-05 00:38:22 +00:00
|
|
|
hideUserNotFoundModal,
|
|
|
|
showUserNotFoundModal,
|
2022-07-21 00:07:09 +00:00
|
|
|
hideStoriesSettings,
|
|
|
|
showStoriesSettings,
|
2022-08-16 23:59:11 +00:00
|
|
|
hideBlockingSafetyNumberChangeDialog,
|
|
|
|
showBlockingSafetyNumberChangeDialog,
|
2023-03-20 22:23:53 +00:00
|
|
|
toggleForwardMessagesModal,
|
2021-07-19 19:26:06 +00:00
|
|
|
toggleProfileEditor,
|
|
|
|
toggleProfileEditorHasError,
|
2021-10-06 20:27:14 +00:00
|
|
|
toggleSafetyNumberModal,
|
2022-09-26 16:24:52 +00:00
|
|
|
toggleAddUserToAnotherGroupModal,
|
2022-07-21 00:07:09 +00:00
|
|
|
toggleSignalConnectionsModal,
|
2023-03-24 21:16:48 +00:00
|
|
|
toggleConfirmationModal,
|
2022-12-08 06:41:37 +00:00
|
|
|
showGV2MigrationDialog,
|
|
|
|
closeGV2MigrationDialog,
|
2022-12-09 19:01:46 +00:00
|
|
|
showStickerPackPreview,
|
|
|
|
closeStickerPackPreview,
|
2022-12-22 03:07:45 +00:00
|
|
|
closeErrorModal,
|
|
|
|
showErrorModal,
|
|
|
|
closeShortcutGuideModal,
|
|
|
|
showShortcutGuideModal,
|
2023-02-27 22:34:43 +00:00
|
|
|
showAuthorizeArtCreator,
|
|
|
|
cancelAuthorizeArtCreator,
|
|
|
|
confirmAuthorizeArtCreator,
|
2021-05-28 16:15:17 +00:00
|
|
|
};
|
|
|
|
|
2022-12-09 17:35:34 +00:00
|
|
|
export const useGlobalModalActions = (): BoundActionCreatorsMapObject<
|
|
|
|
typeof actions
|
|
|
|
> => useBoundActions(actions);
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2021-09-21 22:37:10 +00:00
|
|
|
function hideContactModal(): HideContactModalActionType {
|
|
|
|
return {
|
|
|
|
type: HIDE_CONTACT_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showContactModal(
|
|
|
|
contactId: string,
|
|
|
|
conversationId?: string
|
|
|
|
): ShowContactModalActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_CONTACT_MODAL,
|
|
|
|
payload: {
|
|
|
|
contactId,
|
|
|
|
conversationId,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-23 00:41:45 +00:00
|
|
|
function hideWhatsNewModal(): HideWhatsNewModalActionType {
|
|
|
|
return {
|
|
|
|
type: HIDE_WHATS_NEW_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showWhatsNewModal(): ShowWhatsNewModalActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_WHATS_NEW_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
function hideUserNotFoundModal(): HideUserNotFoundModalActionType {
|
2021-11-12 01:17:29 +00:00
|
|
|
return {
|
2022-04-05 00:38:22 +00:00
|
|
|
type: HIDE_UUID_NOT_FOUND_MODAL,
|
2021-11-12 01:17:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
function showUserNotFoundModal(
|
|
|
|
payload: UserNotFoundModalStateType
|
|
|
|
): ShowUserNotFoundModalActionType {
|
2021-11-12 01:17:29 +00:00
|
|
|
return {
|
2022-04-05 00:38:22 +00:00
|
|
|
type: SHOW_UUID_NOT_FOUND_MODAL,
|
|
|
|
payload,
|
2021-11-12 01:17:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-21 00:07:09 +00:00
|
|
|
function hideStoriesSettings(): HideStoriesSettingsActionType {
|
|
|
|
return { type: HIDE_STORIES_SETTINGS };
|
|
|
|
}
|
|
|
|
|
|
|
|
function showStoriesSettings(): ShowStoriesSettingsActionType {
|
|
|
|
return { type: SHOW_STORIES_SETTINGS };
|
|
|
|
}
|
|
|
|
|
2022-12-08 06:41:37 +00:00
|
|
|
function showGV2MigrationDialog(
|
|
|
|
conversationId: string
|
|
|
|
): ThunkAction<void, RootStateType, unknown, StartMigrationToGV2ActionType> {
|
|
|
|
return async dispatch => {
|
|
|
|
const conversation = window.ConversationController.get(conversationId);
|
|
|
|
if (!conversation) {
|
|
|
|
throw new Error(
|
|
|
|
'showGV2MigrationDialog: Expected a conversation to be found. Doing nothing'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const idForLogging = conversation.idForLogging();
|
|
|
|
|
|
|
|
if (!isGroupV1(conversation.attributes)) {
|
|
|
|
throw new Error(
|
|
|
|
`showGV2MigrationDialog/${idForLogging}: Cannot start, not a GroupV1 group`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: this call will throw if, after generating member lists, we are no longer a
|
|
|
|
// member or are in the pending member list.
|
|
|
|
const { droppedGV2MemberIds, pendingMembersV2 } =
|
|
|
|
await longRunningTaskWrapper({
|
|
|
|
idForLogging,
|
|
|
|
name: 'getGroupMigrationMembers',
|
|
|
|
task: () => getGroupMigrationMembers(conversation),
|
|
|
|
});
|
|
|
|
|
|
|
|
const invitedMemberIds = pendingMembersV2.map(
|
|
|
|
(item: GroupV2PendingMemberType) => item.uuid
|
|
|
|
);
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SHOW_GV2_MIGRATION_DIALOG,
|
|
|
|
payload: {
|
|
|
|
areWeInvited: false,
|
|
|
|
conversationId,
|
|
|
|
droppedMemberIds: droppedGV2MemberIds,
|
|
|
|
hasMigrated: false,
|
|
|
|
invitedMemberIds,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeGV2MigrationDialog(): CloseGV2MigrationDialogActionType {
|
|
|
|
return {
|
|
|
|
type: CLOSE_GV2_MIGRATION_DIALOG,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
function toggleForwardMessagesModal(
|
|
|
|
messageIds?: ReadonlyArray<string>,
|
|
|
|
onForward?: () => void
|
2022-07-01 00:52:03 +00:00
|
|
|
): ThunkAction<
|
|
|
|
void,
|
|
|
|
RootStateType,
|
|
|
|
unknown,
|
2023-03-20 22:23:53 +00:00
|
|
|
ToggleForwardMessagesModalActionType
|
2022-07-01 00:52:03 +00:00
|
|
|
> {
|
|
|
|
return async (dispatch, getState) => {
|
2023-03-20 22:23:53 +00:00
|
|
|
if (!messageIds) {
|
2022-07-01 00:52:03 +00:00
|
|
|
dispatch({
|
2023-03-20 22:23:53 +00:00
|
|
|
type: TOGGLE_FORWARD_MESSAGES_MODAL,
|
2022-07-01 00:52:03 +00:00
|
|
|
payload: undefined,
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
const messagesProps = await Promise.all(
|
|
|
|
messageIds.map(async messageId => {
|
|
|
|
const message = await getMessageById(messageId);
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
if (!message) {
|
|
|
|
throw new Error(
|
|
|
|
`toggleForwardMessagesModal: no message found for ${messageId}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const messagePropsSelector = getMessagePropsSelector(getState());
|
|
|
|
const messageProps = messagePropsSelector(message.attributes);
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
return messageProps;
|
|
|
|
})
|
|
|
|
);
|
2022-07-01 00:52:03 +00:00
|
|
|
|
|
|
|
dispatch({
|
2023-03-20 22:23:53 +00:00
|
|
|
type: TOGGLE_FORWARD_MESSAGES_MODAL,
|
|
|
|
payload: { messages: messagesProps, onForward },
|
2022-07-01 00:52:03 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-19 19:26:06 +00:00
|
|
|
function toggleProfileEditor(): ToggleProfileEditorActionType {
|
|
|
|
return { type: TOGGLE_PROFILE_EDITOR };
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleProfileEditorHasError(): ToggleProfileEditorErrorActionType {
|
|
|
|
return { type: TOGGLE_PROFILE_EDITOR_ERROR };
|
|
|
|
}
|
|
|
|
|
2021-10-06 20:27:14 +00:00
|
|
|
function toggleSafetyNumberModal(
|
|
|
|
safetyNumberModalContactId?: string
|
|
|
|
): ToggleSafetyNumberModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_SAFETY_NUMBER_MODAL,
|
|
|
|
payload: safetyNumberModalContactId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-09-26 16:24:52 +00:00
|
|
|
function toggleAddUserToAnotherGroupModal(
|
|
|
|
contactId?: string
|
|
|
|
): ToggleAddUserToAnotherGroupModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_ADD_USER_TO_ANOTHER_GROUP_MODAL,
|
|
|
|
payload: contactId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-21 00:07:09 +00:00
|
|
|
function toggleSignalConnectionsModal(): ToggleSignalConnectionsModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_SIGNAL_CONNECTIONS_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-24 21:16:48 +00:00
|
|
|
function toggleConfirmationModal(
|
|
|
|
isOpen: boolean
|
|
|
|
): ToggleConfirmationModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_CONFIRMATION_MODAL,
|
|
|
|
payload: isOpen,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-16 23:59:11 +00:00
|
|
|
function showBlockingSafetyNumberChangeDialog(
|
2022-11-11 04:10:30 +00:00
|
|
|
untrustedByConversation: RecipientsByConversation,
|
2022-08-16 23:59:11 +00:00
|
|
|
explodedPromise: ExplodePromiseResultType<boolean>,
|
|
|
|
source?: SafetyNumberChangeSource
|
2022-11-11 04:10:30 +00:00
|
|
|
): ThunkAction<void, RootStateType, unknown, ShowSendAnywayDialogActionType> {
|
2022-08-16 23:59:11 +00:00
|
|
|
const promiseUuid = SingleServePromise.set<boolean>(explodedPromise);
|
|
|
|
|
|
|
|
return dispatch => {
|
|
|
|
dispatch({
|
|
|
|
type: SHOW_SEND_ANYWAY_DIALOG,
|
|
|
|
payload: {
|
2022-11-11 04:10:30 +00:00
|
|
|
untrustedByConversation,
|
2022-08-16 23:59:11 +00:00
|
|
|
promiseUuid,
|
|
|
|
source,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideBlockingSafetyNumberChangeDialog(): HideSendAnywayDialogActiontype {
|
|
|
|
return {
|
|
|
|
type: HIDE_SEND_ANYWAY_DIALOG,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-09 19:01:46 +00:00
|
|
|
function closeStickerPackPreview(): ThunkAction<
|
|
|
|
void,
|
|
|
|
RootStateType,
|
|
|
|
unknown,
|
|
|
|
CloseStickerPackPreviewActionType
|
|
|
|
> {
|
|
|
|
return async (dispatch, getState) => {
|
|
|
|
const packId = getState().globalModals.stickerPackPreviewId;
|
|
|
|
|
2022-12-21 18:41:48 +00:00
|
|
|
if (packId && Stickers.getStickerPack(packId) !== undefined) {
|
|
|
|
await Stickers.removeEphemeralPack(packId);
|
2022-12-09 19:01:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: CLOSE_STICKER_PACK_PREVIEW,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-10 02:02:22 +00:00
|
|
|
export function showStickerPackPreview(
|
2022-12-09 19:01:46 +00:00
|
|
|
packId: string,
|
|
|
|
packKey: string
|
|
|
|
): ShowStickerPackPreviewActionType {
|
|
|
|
// Intentionally not awaiting this so that we can show the modal right away.
|
|
|
|
// The modal has a loading spinner on it.
|
2022-12-21 18:41:48 +00:00
|
|
|
void Stickers.downloadEphemeralPack(packId, packKey);
|
2022-12-09 19:01:46 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
type: SHOW_STICKER_PACK_PREVIEW,
|
|
|
|
payload: packId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
function closeErrorModal(): CloseErrorModalActionType {
|
|
|
|
return {
|
|
|
|
type: CLOSE_ERROR_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showErrorModal({
|
|
|
|
description,
|
|
|
|
title,
|
|
|
|
}: {
|
|
|
|
title?: string;
|
|
|
|
description?: string;
|
|
|
|
}): ShowErrorModalActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_ERROR_MODAL,
|
|
|
|
payload: {
|
|
|
|
description,
|
|
|
|
title,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeShortcutGuideModal(): CloseShortcutGuideModalActionType {
|
|
|
|
return {
|
|
|
|
type: CLOSE_SHORTCUT_GUIDE_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showShortcutGuideModal(): ShowShortcutGuideModalActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_SHORTCUT_GUIDE_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-02-27 22:34:43 +00:00
|
|
|
function cancelAuthorizeArtCreator(): ThunkAction<
|
|
|
|
void,
|
|
|
|
RootStateType,
|
|
|
|
unknown,
|
|
|
|
CancelAuthArtCreatorActionType
|
|
|
|
> {
|
|
|
|
return async (dispatch, getState) => {
|
|
|
|
const data = getState().globalModals.authArtCreatorData;
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: CANCEL_AUTH_ART_CREATOR,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showAuthorizeArtCreator(
|
|
|
|
data: AuthorizeArtCreatorDataType
|
|
|
|
): ShowAuthArtCreatorActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_AUTH_ART_CREATOR,
|
|
|
|
payload: data,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function confirmAuthorizeArtCreator(): ThunkAction<
|
|
|
|
void,
|
|
|
|
RootStateType,
|
|
|
|
unknown,
|
|
|
|
| ConfirmAuthArtCreatorPendingActionType
|
|
|
|
| ConfirmAuthArtCreatorFulfilledActionType
|
|
|
|
| CancelAuthArtCreatorActionType
|
|
|
|
| ShowToastActionType
|
|
|
|
> {
|
|
|
|
return async (dispatch, getState) => {
|
|
|
|
const data = getState().globalModals.authArtCreatorData;
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
dispatch({ type: CANCEL_AUTH_ART_CREATOR });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: CONFIRM_AUTH_ART_CREATOR_PENDING,
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
|
|
await authorizeArtCreator(data);
|
|
|
|
} catch (err) {
|
|
|
|
log.error('authorizeArtCreator failed', Errors.toLogFormat(err));
|
|
|
|
dispatch({
|
|
|
|
type: SHOW_TOAST,
|
|
|
|
payload: {
|
|
|
|
toastType: ToastType.Error,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: CONFIRM_AUTH_ART_CREATOR_FULFILLED,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
// Reducer
|
|
|
|
|
|
|
|
export function getEmptyState(): GlobalModalsStateType {
|
|
|
|
return {
|
2023-03-24 21:16:48 +00:00
|
|
|
hasConfirmationModal: false,
|
2021-07-19 19:26:06 +00:00
|
|
|
isProfileEditorVisible: false,
|
2022-12-22 03:07:45 +00:00
|
|
|
isShortcutGuideModalVisible: false,
|
2022-07-21 00:07:09 +00:00
|
|
|
isSignalConnectionsVisible: false,
|
|
|
|
isStoriesSettingsVisible: false,
|
2021-10-23 00:41:45 +00:00
|
|
|
isWhatsNewVisible: false,
|
2022-07-21 00:07:09 +00:00
|
|
|
profileEditorHasError: false,
|
2021-05-28 16:15:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reducer(
|
|
|
|
state: Readonly<GlobalModalsStateType> = getEmptyState(),
|
|
|
|
action: Readonly<GlobalModalsActionType>
|
|
|
|
): GlobalModalsStateType {
|
2021-07-19 19:26:06 +00:00
|
|
|
if (action.type === TOGGLE_PROFILE_EDITOR) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isProfileEditorVisible: !state.isProfileEditorVisible,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === TOGGLE_PROFILE_EDITOR_ERROR) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
profileEditorHasError: !state.profileEditorHasError,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-23 00:41:45 +00:00
|
|
|
if (action.type === SHOW_WHATS_NEW_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isWhatsNewVisible: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === HIDE_WHATS_NEW_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isWhatsNewVisible: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
if (action.type === HIDE_UUID_NOT_FOUND_MODAL) {
|
2021-11-12 01:17:29 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2022-04-05 00:38:22 +00:00
|
|
|
userNotFoundModalState: undefined,
|
2021-11-12 01:17:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
if (action.type === SHOW_UUID_NOT_FOUND_MODAL) {
|
2021-11-12 01:17:29 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2022-04-05 00:38:22 +00:00
|
|
|
userNotFoundModalState: {
|
|
|
|
...action.payload,
|
2021-11-12 01:17:29 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-21 22:37:10 +00:00
|
|
|
if (action.type === SHOW_CONTACT_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
contactModalState: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === HIDE_CONTACT_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
contactModalState: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-06 20:27:14 +00:00
|
|
|
if (action.type === TOGGLE_SAFETY_NUMBER_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
safetyNumberModalContactId: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-09-26 16:24:52 +00:00
|
|
|
if (action.type === TOGGLE_ADD_USER_TO_ANOTHER_GROUP_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
addUserToAnotherGroupModalContactId: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
if (action.type === TOGGLE_FORWARD_MESSAGES_MODAL) {
|
2022-07-01 00:52:03 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2023-03-20 22:23:53 +00:00
|
|
|
forwardMessagesProps: action.payload,
|
2022-07-01 00:52:03 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-21 00:07:09 +00:00
|
|
|
if (action.type === HIDE_STORIES_SETTINGS) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isStoriesSettingsVisible: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === SHOW_STORIES_SETTINGS) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isStoriesSettingsVisible: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === TOGGLE_SIGNAL_CONNECTIONS_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isSignalConnectionsVisible: !state.isSignalConnectionsVisible,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-24 21:16:48 +00:00
|
|
|
if (action.type === TOGGLE_CONFIRMATION_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
hasConfirmationModal: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-16 23:59:11 +00:00
|
|
|
if (action.type === SHOW_SEND_ANYWAY_DIALOG) {
|
|
|
|
const { promiseUuid, source } = action.payload;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
safetyNumberChangedBlockingData: {
|
|
|
|
promiseUuid,
|
|
|
|
source,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === HIDE_SEND_ANYWAY_DIALOG) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
safetyNumberChangedBlockingData: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-09 19:01:46 +00:00
|
|
|
if (action.type === CLOSE_STICKER_PACK_PREVIEW) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
stickerPackPreviewId: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === SHOW_STICKER_PACK_PREVIEW) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
stickerPackPreviewId: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
if (action.type === CLOSE_ERROR_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
errorModalProps: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === SHOW_ERROR_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
errorModalProps: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === CLOSE_SHORTCUT_GUIDE_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isShortcutGuideModalVisible: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === SHOW_SHORTCUT_GUIDE_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isShortcutGuideModalVisible: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-02-27 22:34:43 +00:00
|
|
|
if (action.type === CANCEL_AUTH_ART_CREATOR) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
authArtCreatorData: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === SHOW_AUTH_ART_CREATOR) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isAuthorizingArtCreator: false,
|
|
|
|
authArtCreatorData: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === CONFIRM_AUTH_ART_CREATOR_PENDING) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isAuthorizingArtCreator: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === CONFIRM_AUTH_ART_CREATOR_FULFILLED) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isAuthorizingArtCreator: false,
|
|
|
|
authArtCreatorData: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
return state;
|
|
|
|
}
|