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';
|
2023-03-27 23:48:57 +00:00
|
|
|
import type {
|
|
|
|
GroupV2PendingMemberType,
|
2024-07-24 20:14:11 +00:00
|
|
|
ReadonlyMessageAttributesType,
|
2023-03-27 23:48:57 +00:00
|
|
|
} from '../../model-types.d';
|
|
|
|
import type {
|
|
|
|
MessageChangedActionType,
|
|
|
|
MessageDeletedActionType,
|
|
|
|
MessageExpiredActionType,
|
|
|
|
} from './conversations';
|
|
|
|
import type { MessagePropsType } 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';
|
2024-01-29 20:09:54 +00:00
|
|
|
import type { EditState as ProfileEditorEditState } from '../../components/ProfileEditor';
|
2022-08-16 23:59:11 +00:00
|
|
|
import type { StateType as RootStateType } from '../reducer';
|
|
|
|
import * as SingleServePromise from '../../services/singleServePromise';
|
2022-12-09 19:01:46 +00:00
|
|
|
import * as Stickers from '../../types/Stickers';
|
2024-01-29 20:09:54 +00:00
|
|
|
import { UsernameOnboardingState } from '../../types/globalModals';
|
2023-03-27 23:48:57 +00:00
|
|
|
import * as log from '../../logging/log';
|
2022-07-01 00:52:03 +00:00
|
|
|
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';
|
|
|
|
import { getGroupMigrationMembers } from '../../groups';
|
2023-03-27 23:48:57 +00:00
|
|
|
import {
|
|
|
|
MESSAGE_CHANGED,
|
|
|
|
MESSAGE_DELETED,
|
|
|
|
MESSAGE_EXPIRED,
|
2023-06-16 18:41:52 +00:00
|
|
|
actions as conversationsActions,
|
2023-03-27 23:48:57 +00:00
|
|
|
} from './conversations';
|
2023-06-16 18:41:52 +00:00
|
|
|
import { isDownloaded } from '../../types/Attachment';
|
2024-02-22 21:19:50 +00:00
|
|
|
import type { ButtonVariant } from '../../components/Button';
|
2024-03-12 16:29:31 +00:00
|
|
|
import type { MessageRequestState } from '../../components/conversation/MessageRequestActionsConfirmation';
|
2024-05-22 16:24:27 +00:00
|
|
|
import type { MessageForwardDraft } from '../../types/ForwardDraft';
|
|
|
|
import { hydrateRanges } from '../../types/BodyRange';
|
|
|
|
import {
|
|
|
|
getConversationSelector,
|
|
|
|
type GetConversationByIdType,
|
|
|
|
} from '../selectors/conversations';
|
|
|
|
import { missingCaseError } from '../../util/missingCaseError';
|
|
|
|
import { ForwardMessagesModalType } from '../../components/ForwardMessagesModal';
|
2024-06-10 15:23:43 +00:00
|
|
|
import type { CallLinkType } from '../../types/CallLink';
|
|
|
|
import type { LocalizerType } from '../../types/I18N';
|
|
|
|
import { linkCallRoute } from '../../util/signalRoutes';
|
2024-07-29 22:35:28 +00:00
|
|
|
import type { StartCallData } from '../../components/ConfirmLeaveCallModal';
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
// State
|
|
|
|
|
2023-03-27 23:48:57 +00:00
|
|
|
export type EditHistoryMessagesType = ReadonlyDeep<
|
2024-07-24 20:14:11 +00:00
|
|
|
Array<ReadonlyMessageAttributesType>
|
2023-03-27 23:48:57 +00:00
|
|
|
>;
|
2024-03-26 19:48:33 +00:00
|
|
|
export type EditNicknameAndNoteModalPropsType = ReadonlyDeep<{
|
|
|
|
conversationId: string;
|
|
|
|
}>;
|
2023-04-10 21:38:34 +00:00
|
|
|
export type DeleteMessagesPropsType = ReadonlyDeep<{
|
|
|
|
conversationId: string;
|
|
|
|
messageIds: ReadonlyArray<string>;
|
|
|
|
onDelete?: () => void;
|
2023-03-24 21:16:48 +00:00
|
|
|
}>;
|
2023-03-27 23:48:57 +00:00
|
|
|
export type ForwardMessagePropsType = ReadonlyDeep<MessagePropsType>;
|
2023-03-20 22:23:53 +00:00
|
|
|
export type ForwardMessagesPropsType = ReadonlyDeep<{
|
2024-05-22 16:24:27 +00:00
|
|
|
type: ForwardMessagesModalType;
|
|
|
|
messageDrafts: Array<MessageForwardDraft>;
|
2023-03-20 22:23:53 +00:00
|
|
|
onForward?: () => void;
|
|
|
|
}>;
|
2024-03-12 16:29:31 +00:00
|
|
|
export type MessageRequestActionsConfirmationPropsType = ReadonlyDeep<{
|
|
|
|
conversationId: string;
|
|
|
|
state: MessageRequestState;
|
|
|
|
}>;
|
2024-03-26 19:48:33 +00:00
|
|
|
export type NotePreviewModalPropsType = ReadonlyDeep<{
|
|
|
|
conversationId: string;
|
|
|
|
}>;
|
2023-01-13 20:07:26 +00:00
|
|
|
export type SafetyNumberChangedBlockingDataType = ReadonlyDeep<{
|
2023-08-10 16:43:33 +00:00
|
|
|
promiseUuid: SingleServePromise.SingleServePromiseIdString;
|
2022-09-26 16:24:52 +00:00
|
|
|
source?: SafetyNumberChangeSource;
|
|
|
|
}>;
|
|
|
|
|
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;
|
2024-02-16 22:16:13 +00:00
|
|
|
aboutContactModalContactId?: string;
|
2024-06-25 18:56:28 +00:00
|
|
|
callLinkAddNameModalRoomId: string | null;
|
2024-06-10 15:23:43 +00:00
|
|
|
callLinkEditModalRoomId: string | null;
|
2024-09-11 19:30:50 +00:00
|
|
|
callLinkPendingParticipantContactId: string | undefined;
|
2024-07-29 22:35:28 +00:00
|
|
|
confirmLeaveCallModalState: StartCallData | null;
|
2022-09-26 16:24:52 +00:00
|
|
|
contactModalState?: ContactModalStateType;
|
2023-04-14 18:16:28 +00:00
|
|
|
deleteMessagesProps?: DeleteMessagesPropsType;
|
2023-03-27 23:48:57 +00:00
|
|
|
editHistoryMessages?: EditHistoryMessagesType;
|
2024-03-26 19:48:33 +00:00
|
|
|
editNicknameAndNoteModalProps: EditNicknameAndNoteModalPropsType | null;
|
2022-12-22 03:07:45 +00:00
|
|
|
errorModalProps?: {
|
2024-02-22 21:19:50 +00:00
|
|
|
buttonVariant?: ButtonVariant;
|
2022-12-22 03:07:45 +00:00
|
|
|
description?: string;
|
2024-10-09 16:35:24 +00:00
|
|
|
title?: string | null;
|
2022-12-22 03:07:45 +00:00
|
|
|
};
|
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;
|
2022-12-22 03:07:45 +00:00
|
|
|
isShortcutGuideModalVisible: boolean;
|
2023-04-14 18:16:28 +00:00
|
|
|
isSignalConnectionsVisible: boolean;
|
2022-09-26 16:24:52 +00:00
|
|
|
isStoriesSettingsVisible: boolean;
|
|
|
|
isWhatsNewVisible: boolean;
|
2024-03-12 16:29:31 +00:00
|
|
|
messageRequestActionsConfirmationProps: MessageRequestActionsConfirmationPropsType | null;
|
2024-03-26 19:48:33 +00:00
|
|
|
notePreviewModalProps: NotePreviewModalPropsType | null;
|
2024-01-29 20:09:54 +00:00
|
|
|
usernameOnboardingState: UsernameOnboardingState;
|
2022-09-26 16:24:52 +00:00
|
|
|
profileEditorHasError: boolean;
|
2024-01-29 20:09:54 +00:00
|
|
|
profileEditorInitialEditState: ProfileEditorEditState | undefined;
|
2022-09-26 16:24:52 +00:00
|
|
|
safetyNumberChangedBlockingData?: SafetyNumberChangedBlockingDataType;
|
|
|
|
safetyNumberModalContactId?: string;
|
2022-12-09 19:01:46 +00:00
|
|
|
stickerPackPreviewId?: string;
|
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';
|
2023-08-10 16:43:33 +00:00
|
|
|
const HIDE_SERVICE_ID_NOT_FOUND_MODAL =
|
|
|
|
'globalModals/HIDE_SERVICE_ID_NOT_FOUND_MODAL';
|
|
|
|
const SHOW_SERVICE_ID_NOT_FOUND_MODAL =
|
|
|
|
'globalModals/SHOW_SERVICE_ID_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-04-10 21:38:34 +00:00
|
|
|
const TOGGLE_DELETE_MESSAGES_MODAL =
|
|
|
|
'globalModals/TOGGLE_DELETE_MESSAGES_MODAL';
|
2023-03-20 22:23:53 +00:00
|
|
|
const TOGGLE_FORWARD_MESSAGES_MODAL =
|
|
|
|
'globalModals/TOGGLE_FORWARD_MESSAGES_MODAL';
|
2024-03-26 19:48:33 +00:00
|
|
|
const TOGGLE_NOTE_PREVIEW_MODAL = 'globalModals/TOGGLE_NOTE_PREVIEW_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';
|
2024-06-25 18:56:28 +00:00
|
|
|
const TOGGLE_CALL_LINK_ADD_NAME_MODAL =
|
|
|
|
'globalModals/TOGGLE_CALL_LINK_ADD_NAME_MODAL';
|
2024-06-10 15:23:43 +00:00
|
|
|
const TOGGLE_CALL_LINK_EDIT_MODAL = 'globalModals/TOGGLE_CALL_LINK_EDIT_MODAL';
|
2024-09-11 19:30:50 +00:00
|
|
|
const TOGGLE_CALL_LINK_PENDING_PARTICIPANT_MODAL =
|
|
|
|
'globalModals/TOGGLE_CALL_LINK_PENDING_PARTICIPANT_MODAL';
|
2024-02-06 02:13:13 +00:00
|
|
|
const TOGGLE_ABOUT_MODAL = 'globalModals/TOGGLE_ABOUT_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';
|
2023-11-08 01:55:48 +00:00
|
|
|
export const SHOW_ERROR_MODAL = 'globalModals/SHOW_ERROR_MODAL';
|
2024-03-26 19:48:33 +00:00
|
|
|
const TOGGLE_EDIT_NICKNAME_AND_NOTE_MODAL =
|
|
|
|
'globalModals/TOGGLE_EDIT_NICKNAME_AND_NOTE_MODAL';
|
2024-03-12 16:29:31 +00:00
|
|
|
const TOGGLE_MESSAGE_REQUEST_ACTIONS_CONFIRMATION =
|
|
|
|
'globalModals/TOGGLE_MESSAGE_REQUEST_ACTIONS_CONFIRMATION';
|
2022-12-22 03:07:45 +00:00
|
|
|
const CLOSE_SHORTCUT_GUIDE_MODAL = 'globalModals/CLOSE_SHORTCUT_GUIDE_MODAL';
|
|
|
|
const SHOW_SHORTCUT_GUIDE_MODAL = 'globalModals/SHOW_SHORTCUT_GUIDE_MODAL';
|
2023-03-24 21:16:48 +00:00
|
|
|
const TOGGLE_CONFIRMATION_MODAL = 'globalModals/TOGGLE_CONFIRMATION_MODAL';
|
2023-03-27 23:48:57 +00:00
|
|
|
const SHOW_EDIT_HISTORY_MODAL = 'globalModals/SHOW_EDIT_HISTORY_MODAL';
|
|
|
|
const CLOSE_EDIT_HISTORY_MODAL = 'globalModals/CLOSE_EDIT_HISTORY_MODAL';
|
2024-01-29 20:09:54 +00:00
|
|
|
const TOGGLE_USERNAME_ONBOARDING = 'globalModals/TOGGLE_USERNAME_ONBOARDING';
|
2024-07-29 22:35:28 +00:00
|
|
|
const TOGGLE_CONFIRM_LEAVE_CALL_MODAL =
|
|
|
|
'globalModals/TOGGLE_CONFIRM_LEAVE_CALL_MODAL';
|
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<{
|
2023-08-10 16:43:33 +00:00
|
|
|
type: typeof HIDE_SERVICE_ID_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<{
|
2023-08-10 16:43:33 +00:00
|
|
|
type: typeof SHOW_SERVICE_ID_NOT_FOUND_MODAL;
|
2022-04-05 00:38:22 +00:00
|
|
|
payload: UserNotFoundModalStateType;
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2021-11-12 01:17:29 +00:00
|
|
|
|
2023-04-10 21:38:34 +00:00
|
|
|
type ToggleDeleteMessagesModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_DELETE_MESSAGES_MODAL;
|
|
|
|
payload: DeleteMessagesPropsType | undefined;
|
|
|
|
}>;
|
|
|
|
|
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
|
|
|
|
2024-07-29 22:35:28 +00:00
|
|
|
export type ToggleConfirmLeaveCallModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_CONFIRM_LEAVE_CALL_MODAL;
|
|
|
|
payload: StartCallData | null;
|
|
|
|
}>;
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
type ToggleNotePreviewModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_NOTE_PREVIEW_MODAL;
|
|
|
|
payload: NotePreviewModalPropsType | null;
|
|
|
|
}>;
|
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
type ToggleProfileEditorActionType = ReadonlyDeep<{
|
2021-07-19 19:26:06 +00:00
|
|
|
type: typeof TOGGLE_PROFILE_EDITOR;
|
2024-01-29 20:09:54 +00:00
|
|
|
payload: {
|
|
|
|
initialEditState?: ProfileEditorEditState;
|
|
|
|
};
|
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
|
|
|
|
2024-06-25 18:56:28 +00:00
|
|
|
type ToggleCallLinkAddNameModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_CALL_LINK_ADD_NAME_MODAL;
|
|
|
|
payload: string | null;
|
|
|
|
}>;
|
|
|
|
|
2024-06-10 15:23:43 +00:00
|
|
|
type ToggleCallLinkEditModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_CALL_LINK_EDIT_MODAL;
|
|
|
|
payload: string | null;
|
|
|
|
}>;
|
|
|
|
|
2024-09-11 19:30:50 +00:00
|
|
|
type ToggleCallLinkPendingParticipantModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_CALL_LINK_PENDING_PARTICIPANT_MODAL;
|
|
|
|
payload: string | undefined;
|
|
|
|
}>;
|
|
|
|
|
2024-02-06 02:13:13 +00:00
|
|
|
type ToggleAboutContactModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_ABOUT_MODAL;
|
2024-02-16 22:16:13 +00:00
|
|
|
payload: string | undefined;
|
2024-02-06 02:13:13 +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;
|
|
|
|
}>;
|
|
|
|
|
2024-01-29 20:09:54 +00:00
|
|
|
type ToggleUsernameOnboardingActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_USERNAME_ONBOARDING;
|
|
|
|
}>;
|
|
|
|
|
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-11-08 01:55:48 +00:00
|
|
|
export type ShowErrorModalActionType = ReadonlyDeep<{
|
2022-12-22 03:07:45 +00:00
|
|
|
type: typeof SHOW_ERROR_MODAL;
|
|
|
|
payload: {
|
2024-02-22 21:19:50 +00:00
|
|
|
buttonVariant?: ButtonVariant;
|
2022-12-22 03:07:45 +00:00
|
|
|
description?: string;
|
2024-10-09 16:35:24 +00:00
|
|
|
title?: string | null;
|
2022-12-22 03:07:45 +00:00
|
|
|
};
|
2023-01-13 20:07:26 +00:00
|
|
|
}>;
|
2022-12-22 03:07:45 +00:00
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
type ToggleEditNicknameAndNoteModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_EDIT_NICKNAME_AND_NOTE_MODAL;
|
|
|
|
payload: EditNicknameAndNoteModalPropsType | null;
|
|
|
|
}>;
|
|
|
|
|
2024-03-12 16:29:31 +00:00
|
|
|
type ToggleMessageRequestActionsConfirmationActionType = ReadonlyDeep<{
|
|
|
|
type: typeof TOGGLE_MESSAGE_REQUEST_ACTIONS_CONFIRMATION;
|
|
|
|
payload: MessageRequestActionsConfirmationPropsType | null;
|
|
|
|
}>;
|
|
|
|
|
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-03-27 23:48:57 +00:00
|
|
|
type ShowEditHistoryModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof SHOW_EDIT_HISTORY_MODAL;
|
|
|
|
payload: {
|
|
|
|
messages: EditHistoryMessagesType;
|
|
|
|
};
|
|
|
|
}>;
|
|
|
|
|
|
|
|
type CloseEditHistoryModalActionType = ReadonlyDeep<{
|
|
|
|
type: typeof CLOSE_EDIT_HISTORY_MODAL;
|
|
|
|
}>;
|
|
|
|
|
2023-01-13 20:07:26 +00:00
|
|
|
export type GlobalModalsActionType = ReadonlyDeep<
|
2023-03-27 23:48:57 +00:00
|
|
|
| CloseEditHistoryModalActionType
|
|
|
|
| CloseErrorModalActionType
|
2022-12-08 06:41:37 +00:00
|
|
|
| CloseGV2MigrationDialogActionType
|
2023-03-27 23:48:57 +00:00
|
|
|
| CloseShortcutGuideModalActionType
|
|
|
|
| CloseStickerPackPreviewActionType
|
2021-09-21 22:37:10 +00:00
|
|
|
| HideContactModalActionType
|
2022-08-16 23:59:11 +00:00
|
|
|
| HideSendAnywayDialogActiontype
|
2023-03-27 23:48:57 +00:00
|
|
|
| HideStoriesSettingsActionType
|
|
|
|
| HideUserNotFoundModalActionType
|
|
|
|
| HideWhatsNewModalActionType
|
|
|
|
| MessageChangedActionType
|
|
|
|
| MessageDeletedActionType
|
|
|
|
| MessageExpiredActionType
|
|
|
|
| ShowContactModalActionType
|
|
|
|
| ShowEditHistoryModalActionType
|
2022-12-22 03:07:45 +00:00
|
|
|
| ShowErrorModalActionType
|
2024-03-26 19:48:33 +00:00
|
|
|
| ToggleEditNicknameAndNoteModalActionType
|
2024-03-12 16:29:31 +00:00
|
|
|
| ToggleMessageRequestActionsConfirmationActionType
|
2023-03-27 23:48:57 +00:00
|
|
|
| ShowSendAnywayDialogActionType
|
2022-12-22 03:07:45 +00:00
|
|
|
| ShowShortcutGuideModalActionType
|
2023-03-27 23:48:57 +00:00
|
|
|
| ShowStickerPackPreviewActionType
|
|
|
|
| ShowStoriesSettingsActionType
|
|
|
|
| ShowUserNotFoundModalActionType
|
|
|
|
| ShowWhatsNewModalActionType
|
|
|
|
| StartMigrationToGV2ActionType
|
2024-02-06 02:13:13 +00:00
|
|
|
| ToggleAboutContactModalActionType
|
2023-03-27 23:48:57 +00:00
|
|
|
| ToggleAddUserToAnotherGroupModalActionType
|
2024-06-25 18:56:28 +00:00
|
|
|
| ToggleCallLinkAddNameModalActionType
|
2024-06-10 15:23:43 +00:00
|
|
|
| ToggleCallLinkEditModalActionType
|
2024-09-11 19:30:50 +00:00
|
|
|
| ToggleCallLinkPendingParticipantModalActionType
|
2023-04-14 18:16:28 +00:00
|
|
|
| ToggleConfirmationModalActionType
|
2024-07-29 22:35:28 +00:00
|
|
|
| ToggleConfirmLeaveCallModalActionType
|
2023-04-10 21:38:34 +00:00
|
|
|
| ToggleDeleteMessagesModalActionType
|
2023-03-20 22:23:53 +00:00
|
|
|
| ToggleForwardMessagesModalActionType
|
2024-03-26 19:48:33 +00:00
|
|
|
| ToggleNotePreviewModalActionType
|
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
|
2023-01-13 20:07:26 +00:00
|
|
|
| ToggleSignalConnectionsModalActionType
|
2024-01-29 20:09:54 +00:00
|
|
|
| ToggleUsernameOnboardingActionType
|
2023-01-13 20:07:26 +00:00
|
|
|
>;
|
2021-05-28 16:15:17 +00:00
|
|
|
|
|
|
|
// Action Creators
|
|
|
|
|
|
|
|
export const actions = {
|
2023-03-27 23:48:57 +00:00
|
|
|
closeEditHistoryModal,
|
|
|
|
closeErrorModal,
|
|
|
|
closeGV2MigrationDialog,
|
|
|
|
closeShortcutGuideModal,
|
|
|
|
closeStickerPackPreview,
|
|
|
|
hideBlockingSafetyNumberChangeDialog,
|
2021-09-21 22:37:10 +00:00
|
|
|
hideContactModal,
|
2022-07-21 00:07:09 +00:00
|
|
|
hideStoriesSettings,
|
2023-03-27 23:48:57 +00:00
|
|
|
hideUserNotFoundModal,
|
|
|
|
hideWhatsNewModal,
|
2022-08-16 23:59:11 +00:00
|
|
|
showBlockingSafetyNumberChangeDialog,
|
2023-03-27 23:48:57 +00:00
|
|
|
showContactModal,
|
|
|
|
showEditHistoryModal,
|
|
|
|
showErrorModal,
|
2024-03-26 19:48:33 +00:00
|
|
|
toggleEditNicknameAndNoteModal,
|
2024-03-12 16:29:31 +00:00
|
|
|
toggleMessageRequestActionsConfirmation,
|
2023-03-27 23:48:57 +00:00
|
|
|
showGV2MigrationDialog,
|
2024-06-10 15:23:43 +00:00
|
|
|
showShareCallLinkViaSignal,
|
2023-03-27 23:48:57 +00:00
|
|
|
showShortcutGuideModal,
|
|
|
|
showStickerPackPreview,
|
|
|
|
showStoriesSettings,
|
|
|
|
showUserNotFoundModal,
|
|
|
|
showWhatsNewModal,
|
2024-02-06 02:13:13 +00:00
|
|
|
toggleAboutContactModal,
|
2023-03-27 23:48:57 +00:00
|
|
|
toggleAddUserToAnotherGroupModal,
|
2024-06-25 18:56:28 +00:00
|
|
|
toggleCallLinkAddNameModal,
|
2024-06-10 15:23:43 +00:00
|
|
|
toggleCallLinkEditModal,
|
2024-09-11 19:30:50 +00:00
|
|
|
toggleCallLinkPendingParticipantModal,
|
2023-03-27 23:48:57 +00:00
|
|
|
toggleConfirmationModal,
|
2024-07-29 22:35:28 +00:00
|
|
|
toggleConfirmLeaveCallModal,
|
2023-04-10 21:38:34 +00:00
|
|
|
toggleDeleteMessagesModal,
|
2023-03-20 22:23:53 +00:00
|
|
|
toggleForwardMessagesModal,
|
2024-03-26 19:48:33 +00:00
|
|
|
toggleNotePreviewModal,
|
2021-07-19 19:26:06 +00:00
|
|
|
toggleProfileEditor,
|
|
|
|
toggleProfileEditorHasError,
|
2021-10-06 20:27:14 +00:00
|
|
|
toggleSafetyNumberModal,
|
2022-07-21 00:07:09 +00:00
|
|
|
toggleSignalConnectionsModal,
|
2024-01-29 20:09:54 +00:00
|
|
|
toggleUsernameOnboarding,
|
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 {
|
2023-08-10 16:43:33 +00:00
|
|
|
type: HIDE_SERVICE_ID_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 {
|
2023-08-10 16:43:33 +00:00
|
|
|
type: SHOW_SERVICE_ID_NOT_FOUND_MODAL,
|
2022-04-05 00:38:22 +00:00
|
|
|
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(
|
2023-08-16 20:54:39 +00:00
|
|
|
(item: GroupV2PendingMemberType) => item.serviceId
|
2022-12-08 06:41:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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-04-10 21:38:34 +00:00
|
|
|
function toggleDeleteMessagesModal(
|
|
|
|
props: DeleteMessagesPropsType | undefined
|
|
|
|
): ToggleDeleteMessagesModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_DELETE_MESSAGES_MODAL,
|
|
|
|
payload: props,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-05-22 16:24:27 +00:00
|
|
|
function toMessageForwardDraft(
|
|
|
|
props: ForwardMessagePropsType,
|
|
|
|
getConversation: GetConversationByIdType
|
|
|
|
): MessageForwardDraft {
|
|
|
|
return {
|
|
|
|
attachments: props.attachments ?? [],
|
|
|
|
bodyRanges: hydrateRanges(props.bodyRanges, getConversation),
|
|
|
|
hasContact: Boolean(props.contact),
|
|
|
|
isSticker: Boolean(props.isSticker),
|
|
|
|
messageBody: props.text,
|
|
|
|
originalMessageId: props.id,
|
|
|
|
previews: props.previews ?? [],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ForwardMessagesPayload = ReadonlyDeep<
|
|
|
|
| {
|
|
|
|
type: ForwardMessagesModalType.Forward;
|
|
|
|
messageIds: ReadonlyArray<string>;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: ForwardMessagesModalType.ShareCallLink;
|
|
|
|
draft: MessageForwardDraft;
|
|
|
|
}
|
|
|
|
>;
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
function toggleForwardMessagesModal(
|
2024-05-22 16:24:27 +00:00
|
|
|
payload: ForwardMessagesPayload | null,
|
2023-03-20 22:23:53 +00:00
|
|
|
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) => {
|
2024-05-22 16:24:27 +00:00
|
|
|
if (payload == null) {
|
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;
|
|
|
|
}
|
|
|
|
|
2024-05-22 16:24:27 +00:00
|
|
|
let messageDrafts: ReadonlyArray<MessageForwardDraft>;
|
2023-06-16 18:41:52 +00:00
|
|
|
|
2024-05-22 16:24:27 +00:00
|
|
|
if (payload.type === ForwardMessagesModalType.Forward) {
|
|
|
|
messageDrafts = await Promise.all(
|
|
|
|
payload.messageIds.map(async messageId => {
|
|
|
|
const messageAttributes = await window.MessageCache.resolveAttributes(
|
|
|
|
'toggleForwardMessagesModal',
|
|
|
|
messageId
|
2023-06-16 18:41:52 +00:00
|
|
|
);
|
|
|
|
|
2024-05-22 16:24:27 +00:00
|
|
|
const { attachments = [] } = messageAttributes;
|
2022-07-01 00:52:03 +00:00
|
|
|
|
2024-05-22 16:24:27 +00:00
|
|
|
if (!attachments.every(isDownloaded)) {
|
|
|
|
dispatch(
|
|
|
|
conversationsActions.kickOffAttachmentDownload({ messageId })
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const state = getState();
|
|
|
|
const messagePropsSelector = getMessagePropsSelector(state);
|
|
|
|
const conversationSelector = getConversationSelector(state);
|
|
|
|
|
|
|
|
const messageProps = messagePropsSelector(messageAttributes);
|
|
|
|
const messageDraft = toMessageForwardDraft(
|
|
|
|
messageProps,
|
|
|
|
conversationSelector
|
|
|
|
);
|
|
|
|
|
|
|
|
return messageDraft;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
} else if (payload.type === ForwardMessagesModalType.ShareCallLink) {
|
|
|
|
messageDrafts = [payload.draft];
|
|
|
|
} else {
|
|
|
|
throw missingCaseError(payload);
|
|
|
|
}
|
2022-07-01 00:52:03 +00:00
|
|
|
|
|
|
|
dispatch({
|
2023-03-20 22:23:53 +00:00
|
|
|
type: TOGGLE_FORWARD_MESSAGES_MODAL,
|
2024-05-22 16:24:27 +00:00
|
|
|
payload: { type: payload.type, messageDrafts, onForward },
|
2022-07-01 00:52:03 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-10 15:23:43 +00:00
|
|
|
function showShareCallLinkViaSignal(
|
|
|
|
callLink: CallLinkType,
|
|
|
|
i18n: LocalizerType
|
|
|
|
): ThunkAction<
|
|
|
|
void,
|
|
|
|
RootStateType,
|
|
|
|
unknown,
|
|
|
|
ToggleForwardMessagesModalActionType
|
|
|
|
> {
|
|
|
|
return dispatch => {
|
|
|
|
const url = linkCallRoute
|
|
|
|
.toWebUrl({
|
|
|
|
key: callLink.rootKey,
|
|
|
|
})
|
|
|
|
.toString();
|
|
|
|
dispatch(
|
|
|
|
toggleForwardMessagesModal({
|
|
|
|
type: ForwardMessagesModalType.ShareCallLink,
|
|
|
|
draft: {
|
|
|
|
originalMessageId: null,
|
|
|
|
hasContact: false,
|
|
|
|
isSticker: false,
|
|
|
|
previews: [
|
|
|
|
{
|
|
|
|
title: callLink.name,
|
|
|
|
url,
|
|
|
|
isCallLink: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
messageBody: i18n(
|
|
|
|
'icu:ShareCallLinkViaSignal__DraftMessageText',
|
2024-07-15 23:15:18 +00:00
|
|
|
{ url },
|
|
|
|
{ bidi: 'strip' }
|
2024-06-10 15:23:43 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-29 22:35:28 +00:00
|
|
|
export function toggleConfirmLeaveCallModal(
|
|
|
|
payload: StartCallData | null
|
|
|
|
): ToggleConfirmLeaveCallModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_CONFIRM_LEAVE_CALL_MODAL,
|
|
|
|
payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
function toggleNotePreviewModal(
|
|
|
|
payload: NotePreviewModalPropsType | null
|
|
|
|
): ToggleNotePreviewModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_NOTE_PREVIEW_MODAL,
|
|
|
|
payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-01-29 20:09:54 +00:00
|
|
|
function toggleProfileEditor(
|
|
|
|
initialEditState?: ProfileEditorEditState
|
|
|
|
): ToggleProfileEditorActionType {
|
|
|
|
return { type: TOGGLE_PROFILE_EDITOR, payload: { initialEditState } };
|
2021-07-19 19:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-25 18:56:28 +00:00
|
|
|
function toggleCallLinkAddNameModal(
|
|
|
|
roomId: string | null
|
|
|
|
): ToggleCallLinkAddNameModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_CALL_LINK_ADD_NAME_MODAL,
|
|
|
|
payload: roomId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-10 15:23:43 +00:00
|
|
|
function toggleCallLinkEditModal(
|
|
|
|
roomId: string | null
|
|
|
|
): ToggleCallLinkEditModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_CALL_LINK_EDIT_MODAL,
|
|
|
|
payload: roomId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-09-11 19:30:50 +00:00
|
|
|
function toggleCallLinkPendingParticipantModal(
|
|
|
|
contactId?: string
|
|
|
|
): ToggleCallLinkPendingParticipantModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_CALL_LINK_PENDING_PARTICIPANT_MODAL,
|
|
|
|
payload: contactId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-02-06 02:13:13 +00:00
|
|
|
function toggleAboutContactModal(
|
|
|
|
contactId?: string
|
|
|
|
): ToggleAboutContactModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_ABOUT_MODAL,
|
2024-02-16 22:16:13 +00:00
|
|
|
payload: contactId,
|
2024-02-06 02:13:13 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-01-29 20:09:54 +00:00
|
|
|
function toggleUsernameOnboarding(): ToggleUsernameOnboardingActionType {
|
|
|
|
return { type: TOGGLE_USERNAME_ONBOARDING };
|
|
|
|
}
|
|
|
|
|
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({
|
2024-02-22 21:19:50 +00:00
|
|
|
buttonVariant,
|
2022-12-22 03:07:45 +00:00
|
|
|
description,
|
|
|
|
title,
|
|
|
|
}: {
|
2024-02-22 21:19:50 +00:00
|
|
|
buttonVariant?: ButtonVariant;
|
2022-12-22 03:07:45 +00:00
|
|
|
description?: string;
|
2024-02-22 21:19:50 +00:00
|
|
|
title?: string;
|
2022-12-22 03:07:45 +00:00
|
|
|
}): ShowErrorModalActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_ERROR_MODAL,
|
|
|
|
payload: {
|
2024-02-22 21:19:50 +00:00
|
|
|
buttonVariant,
|
2022-12-22 03:07:45 +00:00
|
|
|
description,
|
|
|
|
title,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
function toggleEditNicknameAndNoteModal(
|
|
|
|
payload: EditNicknameAndNoteModalPropsType | null
|
|
|
|
): ToggleEditNicknameAndNoteModalActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_EDIT_NICKNAME_AND_NOTE_MODAL,
|
|
|
|
payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-03-12 16:29:31 +00:00
|
|
|
function toggleMessageRequestActionsConfirmation(
|
|
|
|
payload: {
|
|
|
|
conversationId: string;
|
|
|
|
state: MessageRequestState;
|
|
|
|
} | null
|
|
|
|
): ToggleMessageRequestActionsConfirmationActionType {
|
|
|
|
return {
|
|
|
|
type: TOGGLE_MESSAGE_REQUEST_ACTIONS_CONFIRMATION,
|
|
|
|
payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
function closeShortcutGuideModal(): CloseShortcutGuideModalActionType {
|
|
|
|
return {
|
|
|
|
type: CLOSE_SHORTCUT_GUIDE_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showShortcutGuideModal(): ShowShortcutGuideModalActionType {
|
|
|
|
return {
|
|
|
|
type: SHOW_SHORTCUT_GUIDE_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-27 23:48:57 +00:00
|
|
|
function copyOverMessageAttributesIntoEditHistory(
|
2024-07-24 20:14:11 +00:00
|
|
|
messageAttributes: ReadonlyDeep<ReadonlyMessageAttributesType>
|
2023-03-27 23:48:57 +00:00
|
|
|
): EditHistoryMessagesType | undefined {
|
|
|
|
if (!messageAttributes.editHistory) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return messageAttributes.editHistory.map(editedMessageAttributes => ({
|
|
|
|
...messageAttributes,
|
2023-04-20 16:31:59 +00:00
|
|
|
// Always take attachments from the edited message (they might be absent)
|
|
|
|
attachments: undefined,
|
2023-07-05 22:38:37 +00:00
|
|
|
editMessageTimestamp: undefined,
|
2023-04-20 16:31:59 +00:00
|
|
|
quote: undefined,
|
|
|
|
preview: [],
|
2023-03-27 23:48:57 +00:00
|
|
|
...editedMessageAttributes,
|
|
|
|
// For timestamp uniqueness of messages
|
|
|
|
sent_at: editedMessageAttributes.timestamp,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
function showEditHistoryModal(
|
|
|
|
messageId: string
|
|
|
|
): ThunkAction<void, RootStateType, unknown, ShowEditHistoryModalActionType> {
|
|
|
|
return async dispatch => {
|
2023-10-04 00:12:57 +00:00
|
|
|
const messageAttributes = await window.MessageCache.resolveAttributes(
|
|
|
|
'showEditHistoryModal',
|
|
|
|
messageId
|
|
|
|
);
|
2023-03-27 23:48:57 +00:00
|
|
|
const nextEditHistoryMessages =
|
|
|
|
copyOverMessageAttributesIntoEditHistory(messageAttributes);
|
|
|
|
|
|
|
|
if (!nextEditHistoryMessages) {
|
|
|
|
log.warn('showEditHistoryModal: no edit history for message');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SHOW_EDIT_HISTORY_MODAL,
|
|
|
|
payload: {
|
|
|
|
messages: nextEditHistoryMessages,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeEditHistoryModal(): CloseEditHistoryModalActionType {
|
|
|
|
return {
|
|
|
|
type: CLOSE_EDIT_HISTORY_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
function copyOverMessageAttributesIntoForwardMessages(
|
2024-05-22 16:24:27 +00:00
|
|
|
messageDrafts: ReadonlyArray<MessageForwardDraft>,
|
2024-07-24 20:14:11 +00:00
|
|
|
attributes: ReadonlyDeep<ReadonlyMessageAttributesType>
|
2024-05-22 16:24:27 +00:00
|
|
|
): ReadonlyArray<MessageForwardDraft> {
|
|
|
|
return messageDrafts.map(messageDraft => {
|
|
|
|
if (messageDraft.originalMessageId !== attributes.id) {
|
|
|
|
return messageDraft;
|
2023-06-16 18:41:52 +00:00
|
|
|
}
|
|
|
|
return {
|
2024-05-22 16:24:27 +00:00
|
|
|
...messageDraft,
|
2023-06-16 18:41:52 +00:00
|
|
|
attachments: attributes.attachments,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
// Reducer
|
|
|
|
|
|
|
|
export function getEmptyState(): GlobalModalsStateType {
|
|
|
|
return {
|
2023-03-24 21:16:48 +00:00
|
|
|
hasConfirmationModal: false,
|
2024-06-25 18:56:28 +00:00
|
|
|
callLinkAddNameModalRoomId: null,
|
2024-06-10 15:23:43 +00:00
|
|
|
callLinkEditModalRoomId: null,
|
2024-09-11 19:30:50 +00:00
|
|
|
callLinkPendingParticipantContactId: undefined,
|
2024-07-29 22:35:28 +00:00
|
|
|
confirmLeaveCallModalState: null,
|
2024-03-26 19:48:33 +00:00
|
|
|
editNicknameAndNoteModalProps: null,
|
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,
|
2024-01-29 20:09:54 +00:00
|
|
|
usernameOnboardingState: UsernameOnboardingState.NeverShown,
|
2022-07-21 00:07:09 +00:00
|
|
|
profileEditorHasError: false,
|
2024-01-29 20:09:54 +00:00
|
|
|
profileEditorInitialEditState: undefined,
|
2024-03-12 16:29:31 +00:00
|
|
|
messageRequestActionsConfirmationProps: null,
|
2024-03-26 19:48:33 +00:00
|
|
|
notePreviewModalProps: null,
|
2021-05-28 16:15:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reducer(
|
|
|
|
state: Readonly<GlobalModalsStateType> = getEmptyState(),
|
|
|
|
action: Readonly<GlobalModalsActionType>
|
|
|
|
): GlobalModalsStateType {
|
2024-02-06 02:13:13 +00:00
|
|
|
if (action.type === TOGGLE_ABOUT_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
2024-02-16 22:16:13 +00:00
|
|
|
aboutContactModalContactId: action.payload,
|
2024-02-06 02:13:13 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-29 22:35:28 +00:00
|
|
|
if (action.type === TOGGLE_CONFIRM_LEAVE_CALL_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
confirmLeaveCallModalState: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
if (action.type === TOGGLE_NOTE_PREVIEW_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
notePreviewModalProps: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-19 19:26:06 +00:00
|
|
|
if (action.type === TOGGLE_PROFILE_EDITOR) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isProfileEditorVisible: !state.isProfileEditorVisible,
|
2024-01-29 20:09:54 +00:00
|
|
|
profileEditorInitialEditState: action.payload.initialEditState,
|
2021-07-19 19:26:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
if (action.type === HIDE_SERVICE_ID_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
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
if (action.type === SHOW_SERVICE_ID_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) {
|
2024-02-16 22:16:13 +00:00
|
|
|
const ourId = window.ConversationController.getOurConversationIdOrThrow();
|
|
|
|
if (action.payload.contactId === ourId) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
aboutContactModalContactId: ourId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-21 22:37:10 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-25 18:56:28 +00:00
|
|
|
if (action.type === TOGGLE_CALL_LINK_ADD_NAME_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
callLinkAddNameModalRoomId: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-10 15:23:43 +00:00
|
|
|
if (action.type === TOGGLE_CALL_LINK_EDIT_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
callLinkEditModalRoomId: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-09-11 19:30:50 +00:00
|
|
|
if (action.type === TOGGLE_CALL_LINK_PENDING_PARTICIPANT_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
callLinkPendingParticipantContactId: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-04-10 21:38:34 +00:00
|
|
|
if (action.type === TOGGLE_DELETE_MESSAGES_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
deleteMessagesProps: 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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-01-29 20:09:54 +00:00
|
|
|
if (action.type === TOGGLE_USERNAME_ONBOARDING) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
usernameOnboardingState:
|
|
|
|
state.usernameOnboardingState === UsernameOnboardingState.Open
|
|
|
|
? UsernameOnboardingState.Closed
|
|
|
|
: UsernameOnboardingState.Open,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
};
|
2024-03-26 19:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === TOGGLE_EDIT_NICKNAME_AND_NOTE_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editNicknameAndNoteModalProps: action.payload,
|
|
|
|
};
|
2022-12-22 03:07:45 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 16:29:31 +00:00
|
|
|
if (action.type === TOGGLE_MESSAGE_REQUEST_ACTIONS_CONFIRMATION) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
messageRequestActionsConfirmationProps: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
if (action.type === CLOSE_SHORTCUT_GUIDE_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isShortcutGuideModalVisible: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === SHOW_SHORTCUT_GUIDE_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isShortcutGuideModalVisible: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-27 23:48:57 +00:00
|
|
|
if (action.type === SHOW_EDIT_HISTORY_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editHistoryMessages: action.payload.messages,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === CLOSE_EDIT_HISTORY_MODAL) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editHistoryMessages: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
if (state.forwardMessagesProps != null) {
|
|
|
|
if (action.type === MESSAGE_CHANGED) {
|
|
|
|
if (
|
2024-05-22 16:24:27 +00:00
|
|
|
!state.forwardMessagesProps.messageDrafts.some(message => {
|
|
|
|
return message.originalMessageId === action.payload.id;
|
2023-06-16 18:41:52 +00:00
|
|
|
})
|
|
|
|
) {
|
2023-03-27 23:48:57 +00:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
2023-06-16 18:41:52 +00:00
|
|
|
forwardMessagesProps: {
|
|
|
|
...state.forwardMessagesProps,
|
2024-05-22 16:24:27 +00:00
|
|
|
messageDrafts: copyOverMessageAttributesIntoForwardMessages(
|
|
|
|
state.forwardMessagesProps.messageDrafts,
|
2023-06-16 18:41:52 +00:00
|
|
|
action.payload.data
|
|
|
|
),
|
|
|
|
},
|
2023-03-27 23:48:57 +00:00
|
|
|
};
|
|
|
|
}
|
2023-06-16 18:41:52 +00:00
|
|
|
}
|
2023-03-27 23:48:57 +00:00
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
if (state.editHistoryMessages != null) {
|
|
|
|
if (
|
|
|
|
action.type === MESSAGE_CHANGED ||
|
|
|
|
action.type === MESSAGE_DELETED ||
|
|
|
|
action.type === MESSAGE_EXPIRED
|
|
|
|
) {
|
|
|
|
if (action.type === MESSAGE_DELETED || action.type === MESSAGE_EXPIRED) {
|
|
|
|
const hasMessageId = state.editHistoryMessages.some(
|
|
|
|
edit => edit.id === action.payload.id
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!hasMessageId) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editHistoryMessages: undefined,
|
|
|
|
};
|
2023-03-27 23:48:57 +00:00
|
|
|
}
|
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
if (action.type === MESSAGE_CHANGED) {
|
|
|
|
if (!action.payload.data.editHistory) {
|
|
|
|
return state;
|
|
|
|
}
|
2023-03-27 23:48:57 +00:00
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
const hasMessageId = state.editHistoryMessages.some(
|
|
|
|
edit => edit.id === action.payload.id
|
|
|
|
);
|
2023-03-27 23:48:57 +00:00
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
if (!hasMessageId) {
|
|
|
|
return state;
|
|
|
|
}
|
2023-03-27 23:48:57 +00:00
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
const nextEditHistoryMessages =
|
|
|
|
copyOverMessageAttributesIntoEditHistory(action.payload.data);
|
2023-03-27 23:48:57 +00:00
|
|
|
|
2023-06-16 18:41:52 +00:00
|
|
|
if (!nextEditHistoryMessages) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editHistoryMessages: nextEditHistoryMessages,
|
|
|
|
};
|
|
|
|
}
|
2023-03-27 23:48:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
return state;
|
|
|
|
}
|