Move ToastType to its own file to avoid importing electron in storybooks

This commit is contained in:
Jamie Kyle 2022-12-14 16:48:36 -08:00 committed by GitHub
parent daf66f33da
commit 15efbde23d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 57 additions and 49 deletions

View file

@ -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';

View file

@ -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';

View file

@ -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;

View file

@ -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';

View file

@ -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,

View file

@ -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';

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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 = {

View file

@ -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<{

View file

@ -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,

View file

@ -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';

34
ts/types/Toast.tsx Normal file
View file

@ -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',
}

View file

@ -3,7 +3,7 @@
import type { ConversationAttributesType } from '../model-types';
import { ToastType } from '../state/ducks/toast';
import { ToastType } from '../types/Toast';
import {
isDirectConversation,
isGroupV1,