diff --git a/ts/components/AddUserToAnotherGroupModal.tsx b/ts/components/AddUserToAnotherGroupModal.tsx index 11d4414e5b..7b35aa99dc 100644 --- a/ts/components/AddUserToAnotherGroupModal.tsx +++ b/ts/components/AddUserToAnotherGroupModal.tsx @@ -12,7 +12,7 @@ import type { ReplacementValuesType, ThemeType, } from '../types/Util'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; import { filterAndSortConversationsByRecent } from '../util/filterAndSortConversations'; import { ConfirmationDialog } from './ConfirmationDialog'; import type { Row } from './ConversationList'; diff --git a/ts/components/App.tsx b/ts/components/App.tsx index 16575d8dbd..f0ab191931 100644 --- a/ts/components/App.tsx +++ b/ts/components/App.tsx @@ -8,7 +8,7 @@ import classNames from 'classnames'; import type { ExecuteMenuRoleType } from './TitleBarContainer'; import type { MenuOptionsType, MenuActionType } from '../types/menu'; -import type { ToastType } from '../state/ducks/toast'; +import type { ToastType } from '../types/Toast'; import type { ViewStoryActionCreatorType } from '../state/ducks/stories'; import type { ReplacementValuesType } from '../types/Util'; import { ThemeType } from '../types/Util'; diff --git a/ts/components/ErrorBoundary.tsx b/ts/components/ErrorBoundary.tsx index e93a90969c..64c828b146 100644 --- a/ts/components/ErrorBoundary.tsx +++ b/ts/components/ErrorBoundary.tsx @@ -6,7 +6,7 @@ import React from 'react'; import * as Errors from '../types/errors'; import * as log from '../logging/log'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; export type Props = { children: ReactNode; diff --git a/ts/components/ProfileEditor.tsx b/ts/components/ProfileEditor.tsx index e54c996868..7e8a9ca7ef 100644 --- a/ts/components/ProfileEditor.tsx +++ b/ts/components/ProfileEditor.tsx @@ -27,7 +27,7 @@ import { Modal } from './Modal'; import { PanelRow } from './conversation/conversation-details/PanelRow'; import type { ProfileDataType } from '../state/ducks/conversations'; import { UsernameEditState } from '../state/ducks/usernameEnums'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; import type { ShowToastActionCreatorType } from '../state/ducks/toast'; import { getEmojiData, unifiedToEmoji } from './emoji/lib'; import { assertDev } from '../util/assert'; diff --git a/ts/components/StoriesAddStoryButton.tsx b/ts/components/StoriesAddStoryButton.tsx index 4090adce34..c892526d6b 100644 --- a/ts/components/StoriesAddStoryButton.tsx +++ b/ts/components/StoriesAddStoryButton.tsx @@ -8,7 +8,7 @@ import type { LocalizerType } from '../types/Util'; import type { ShowToastActionCreatorType } from '../state/ducks/toast'; import { ContextMenu } from './ContextMenu'; import { Theme } from '../util/theme'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; import { isVideoGoodForStories, ReasonVideoNotGood, diff --git a/ts/components/StoryViewer.tsx b/ts/components/StoryViewer.tsx index f9ccad5b93..804d505901 100644 --- a/ts/components/StoryViewer.tsx +++ b/ts/components/StoryViewer.tsx @@ -43,7 +43,7 @@ import { } from '../types/Stories'; import { StoryViewsNRepliesModal } from './StoryViewsNRepliesModal'; import { Theme } from '../util/theme'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; import { getAvatarColor } from '../types/Colors'; import { getStoryBackground } from '../util/getStoryBackground'; import { getStoryDuration } from '../util/getStoryDuration'; diff --git a/ts/components/ToastManager.stories.tsx b/ts/components/ToastManager.stories.tsx index 95bd758ec5..b1b1556550 100644 --- a/ts/components/ToastManager.stories.tsx +++ b/ts/components/ToastManager.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { PropsType } from './ToastManager'; import enMessages from '../../_locales/en/messages.json'; import { ToastManager } from './ToastManager'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; import { setupI18n } from '../util/setupI18n'; const i18n = setupI18n('en', enMessages); diff --git a/ts/components/ToastManager.tsx b/ts/components/ToastManager.tsx index 62075b010d..988971a473 100644 --- a/ts/components/ToastManager.tsx +++ b/ts/components/ToastManager.tsx @@ -6,8 +6,8 @@ import type { LocalizerType, ReplacementValuesType } from '../types/Util'; import { SECOND } from '../util/durations'; import { Toast } from './Toast'; import { ToastMessageBodyTooLong } from './ToastMessageBodyTooLong'; -import { ToastType } from '../state/ducks/toast'; import { missingCaseError } from '../util/missingCaseError'; +import { ToastType } from '../types/Toast'; export type PropsType = { hideToast: () => unknown; diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index 07f0d0dd30..1eb14dfa50 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -49,7 +49,8 @@ import { waitForOnline } from '../../util/waitForOnline'; import * as mapUtil from '../../util/mapUtil'; import { isCallSafe } from '../../util/isCallSafe'; import { isDirectConversation } from '../../util/whatTypeOfConversation'; -import { SHOW_TOAST, ToastType } from './toast'; +import { SHOW_TOAST } from './toast'; +import { ToastType } from '../../types/Toast'; import type { ShowToastActionType } from './toast'; // State diff --git a/ts/state/ducks/composer.ts b/ts/state/ducks/composer.ts index 9d866bdf08..c239398081 100644 --- a/ts/state/ducks/composer.ts +++ b/ts/state/ducks/composer.ts @@ -33,7 +33,8 @@ import { } from './linkPreviews'; import { LinkPreviewSourceType } from '../../types/LinkPreview'; import { RecordingState } from './audioRecorder'; -import { SHOW_TOAST, ToastType } from './toast'; +import { SHOW_TOAST } from './toast'; +import { ToastType } from '../../types/Toast'; import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog'; import { UUID } from '../../types/UUID'; import { assignWithNoUnnecessaryAllocation } from '../../util/assignWithNoUnnecessaryAllocation'; diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index b039b6ae84..10dc83f5b1 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -104,7 +104,8 @@ import { ReadStatus } from '../../messages/MessageReadStatus'; import { isIncoming, isOutgoing } from '../selectors/message'; import { sendDeleteForEveryoneMessage } from '../../util/sendDeleteForEveryoneMessage'; import type { ShowToastActionType } from './toast'; -import { SHOW_TOAST, ToastType } from './toast'; +import { SHOW_TOAST } from './toast'; +import { ToastType } from '../../types/Toast'; import { isMemberRequestingToJoin } from '../../util/isMemberRequestingToJoin'; import { removePendingMember } from '../../util/removePendingMember'; import { denyPendingApprovalRequest } from '../../util/denyPendingApprovalRequest'; diff --git a/ts/state/ducks/lightbox.ts b/ts/state/ducks/lightbox.ts index 16e35cdd03..b95dcd3172 100644 --- a/ts/state/ducks/lightbox.ts +++ b/ts/state/ducks/lightbox.ts @@ -18,7 +18,8 @@ import { isVideoTypeSupported, } from '../../util/GoogleChrome'; import { isTapToView } from '../selectors/message'; -import { SHOW_TOAST, ToastType } from './toast'; +import { SHOW_TOAST } from './toast'; +import { ToastType } from '../../types/Toast'; import { saveAttachmentFromMessage } from './conversations'; import { showStickerPackPreview } from './globalModals'; import { useBoundActions } from '../../hooks/useBoundActions'; diff --git a/ts/state/ducks/toast.ts b/ts/state/ducks/toast.ts index c5015c5b52..b203a71bd0 100644 --- a/ts/state/ducks/toast.ts +++ b/ts/state/ducks/toast.ts @@ -7,39 +7,7 @@ import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions'; import type { NoopActionType } from './noop'; import type { ReplacementValuesType } from '../../types/Util'; import { useBoundActions } from '../../hooks/useBoundActions'; - -export enum ToastType { - AddingUserToGroup = 'AddingUserToGroup', - Blocked = 'Blocked', - BlockedGroup = 'BlockedGroup', - CannotMixMultiAndNonMultiAttachments = 'CannotMixMultiAndNonMultiAttachments', - CannotStartGroupCall = 'CannotStartGroupCall', - CopiedUsername = 'CopiedUsername', - CopiedUsernameLink = 'CopiedUsernameLink', - DangerousFileType = 'DangerousFileType', - DeleteForEveryoneFailed = 'DeleteForEveryoneFailed', - Error = 'Error', - Expired = 'Expired', - FailedToDeleteUsername = 'FailedToDeleteUsername', - FileSaved = 'FileSaved', - FileSize = 'FileSize', - InvalidConversation = 'InvalidConversation', - LeftGroup = 'LeftGroup', - MaxAttachments = 'MaxAttachments', - MessageBodyTooLong = 'MessageBodyTooLong', - PinnedConversationsFull = 'PinnedConversationsFull', - ReportedSpamAndBlocked = 'ReportedSpamAndBlocked', - StoryMuted = 'StoryMuted', - StoryReact = 'StoryReact', - StoryReply = 'StoryReply', - StoryVideoError = 'StoryVideoError', - StoryVideoTooLong = 'StoryVideoTooLong', - StoryVideoUnsupported = 'StoryVideoUnsupported', - UnableToLoadAttachment = 'UnableToLoadAttachment', - UnsupportedMultiAttachment = 'UnsupportedMultiAttachment', - UserAddedToGroup = 'UserAddedToGroup', -} - +import type { ToastType } from '../../types/Toast'; // State export type ToastStateType = { diff --git a/ts/state/ducks/username.ts b/ts/state/ducks/username.ts index bdfb49aa94..2e4dee3f89 100644 --- a/ts/state/ducks/username.ts +++ b/ts/state/ducks/username.ts @@ -23,7 +23,8 @@ import { UsernameReservationState, UsernameReservationError, } from './usernameEnums'; -import { showToast, ToastType } from './toast'; +import { showToast } from './toast'; +import { ToastType } from '../../types/Toast'; import type { ToastActionType } from './toast'; export type UsernameReservationStateType = Readonly<{ diff --git a/ts/state/smart/StoryViewer.tsx b/ts/state/smart/StoryViewer.tsx index f4bcc3210c..442f5b85d9 100644 --- a/ts/state/smart/StoryViewer.tsx +++ b/ts/state/smart/StoryViewer.tsx @@ -9,7 +9,8 @@ import type { LocalizerType } from '../../types/Util'; import type { StateType } from '../reducer'; import type { SelectedStoryDataType } from '../ducks/stories'; import { StoryViewer } from '../../components/StoryViewer'; -import { ToastType, useToastActions } from '../ducks/toast'; +import { ToastType } from '../../types/Toast'; +import { useToastActions } from '../ducks/toast'; import { getConversationSelector } from '../selectors/conversations'; import { getEmojiSkinTone, diff --git a/ts/test-electron/state/ducks/username_test.ts b/ts/test-electron/state/ducks/username_test.ts index 0d3d60bb8a..98c74dbc22 100644 --- a/ts/test-electron/state/ducks/username_test.ts +++ b/ts/test-electron/state/ducks/username_test.ts @@ -17,7 +17,7 @@ import { UsernameReservationError, } from '../../../state/ducks/usernameEnums'; import { actions } from '../../../state/ducks/username'; -import { ToastType } from '../../../state/ducks/toast'; +import { ToastType } from '../../../types/Toast'; import { noopAction } from '../../../state/ducks/noop'; import { reducer } from '../../../state/reducer'; import { ReserveUsernameError } from '../../../types/Username'; diff --git a/ts/types/Toast.tsx b/ts/types/Toast.tsx new file mode 100644 index 0000000000..b398b4cbda --- /dev/null +++ b/ts/types/Toast.tsx @@ -0,0 +1,34 @@ +// Copyright 2022 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +export enum ToastType { + AddingUserToGroup = 'AddingUserToGroup', + Blocked = 'Blocked', + BlockedGroup = 'BlockedGroup', + CannotMixMultiAndNonMultiAttachments = 'CannotMixMultiAndNonMultiAttachments', + CannotStartGroupCall = 'CannotStartGroupCall', + CopiedUsername = 'CopiedUsername', + CopiedUsernameLink = 'CopiedUsernameLink', + DangerousFileType = 'DangerousFileType', + DeleteForEveryoneFailed = 'DeleteForEveryoneFailed', + Error = 'Error', + Expired = 'Expired', + FailedToDeleteUsername = 'FailedToDeleteUsername', + FileSaved = 'FileSaved', + FileSize = 'FileSize', + InvalidConversation = 'InvalidConversation', + LeftGroup = 'LeftGroup', + MaxAttachments = 'MaxAttachments', + MessageBodyTooLong = 'MessageBodyTooLong', + PinnedConversationsFull = 'PinnedConversationsFull', + ReportedSpamAndBlocked = 'ReportedSpamAndBlocked', + StoryMuted = 'StoryMuted', + StoryReact = 'StoryReact', + StoryReply = 'StoryReply', + StoryVideoError = 'StoryVideoError', + StoryVideoTooLong = 'StoryVideoTooLong', + StoryVideoUnsupported = 'StoryVideoUnsupported', + UnableToLoadAttachment = 'UnableToLoadAttachment', + UnsupportedMultiAttachment = 'UnsupportedMultiAttachment', + UserAddedToGroup = 'UserAddedToGroup', +} diff --git a/ts/util/shouldShowInvalidMessageToast.ts b/ts/util/shouldShowInvalidMessageToast.ts index 1833614a2f..27802082a7 100644 --- a/ts/util/shouldShowInvalidMessageToast.ts +++ b/ts/util/shouldShowInvalidMessageToast.ts @@ -3,7 +3,7 @@ import type { ConversationAttributesType } from '../model-types'; -import { ToastType } from '../state/ducks/toast'; +import { ToastType } from '../types/Toast'; import { isDirectConversation, isGroupV1,