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, ReplacementValuesType,
ThemeType, ThemeType,
} from '../types/Util'; } from '../types/Util';
import { ToastType } from '../state/ducks/toast'; import { ToastType } from '../types/Toast';
import { filterAndSortConversationsByRecent } from '../util/filterAndSortConversations'; import { filterAndSortConversationsByRecent } from '../util/filterAndSortConversations';
import { ConfirmationDialog } from './ConfirmationDialog'; import { ConfirmationDialog } from './ConfirmationDialog';
import type { Row } from './ConversationList'; import type { Row } from './ConversationList';

View file

@ -8,7 +8,7 @@ import classNames from 'classnames';
import type { ExecuteMenuRoleType } from './TitleBarContainer'; import type { ExecuteMenuRoleType } from './TitleBarContainer';
import type { MenuOptionsType, MenuActionType } from '../types/menu'; 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 { ViewStoryActionCreatorType } from '../state/ducks/stories';
import type { ReplacementValuesType } from '../types/Util'; import type { ReplacementValuesType } from '../types/Util';
import { ThemeType } 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 Errors from '../types/errors';
import * as log from '../logging/log'; import * as log from '../logging/log';
import { ToastType } from '../state/ducks/toast'; import { ToastType } from '../types/Toast';
export type Props = { export type Props = {
children: ReactNode; children: ReactNode;

View file

@ -27,7 +27,7 @@ import { Modal } from './Modal';
import { PanelRow } from './conversation/conversation-details/PanelRow'; import { PanelRow } from './conversation/conversation-details/PanelRow';
import type { ProfileDataType } from '../state/ducks/conversations'; import type { ProfileDataType } from '../state/ducks/conversations';
import { UsernameEditState } from '../state/ducks/usernameEnums'; 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 type { ShowToastActionCreatorType } from '../state/ducks/toast';
import { getEmojiData, unifiedToEmoji } from './emoji/lib'; import { getEmojiData, unifiedToEmoji } from './emoji/lib';
import { assertDev } from '../util/assert'; 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 type { ShowToastActionCreatorType } from '../state/ducks/toast';
import { ContextMenu } from './ContextMenu'; import { ContextMenu } from './ContextMenu';
import { Theme } from '../util/theme'; import { Theme } from '../util/theme';
import { ToastType } from '../state/ducks/toast'; import { ToastType } from '../types/Toast';
import { import {
isVideoGoodForStories, isVideoGoodForStories,
ReasonVideoNotGood, ReasonVideoNotGood,

View file

@ -43,7 +43,7 @@ import {
} from '../types/Stories'; } from '../types/Stories';
import { StoryViewsNRepliesModal } from './StoryViewsNRepliesModal'; import { StoryViewsNRepliesModal } from './StoryViewsNRepliesModal';
import { Theme } from '../util/theme'; import { Theme } from '../util/theme';
import { ToastType } from '../state/ducks/toast'; import { ToastType } from '../types/Toast';
import { getAvatarColor } from '../types/Colors'; import { getAvatarColor } from '../types/Colors';
import { getStoryBackground } from '../util/getStoryBackground'; import { getStoryBackground } from '../util/getStoryBackground';
import { getStoryDuration } from '../util/getStoryDuration'; import { getStoryDuration } from '../util/getStoryDuration';

View file

@ -7,7 +7,7 @@ import React from 'react';
import type { PropsType } from './ToastManager'; import type { PropsType } from './ToastManager';
import enMessages from '../../_locales/en/messages.json'; import enMessages from '../../_locales/en/messages.json';
import { ToastManager } from './ToastManager'; import { ToastManager } from './ToastManager';
import { ToastType } from '../state/ducks/toast'; import { ToastType } from '../types/Toast';
import { setupI18n } from '../util/setupI18n'; import { setupI18n } from '../util/setupI18n';
const i18n = setupI18n('en', enMessages); const i18n = setupI18n('en', enMessages);

View file

@ -6,8 +6,8 @@ import type { LocalizerType, ReplacementValuesType } from '../types/Util';
import { SECOND } from '../util/durations'; import { SECOND } from '../util/durations';
import { Toast } from './Toast'; import { Toast } from './Toast';
import { ToastMessageBodyTooLong } from './ToastMessageBodyTooLong'; import { ToastMessageBodyTooLong } from './ToastMessageBodyTooLong';
import { ToastType } from '../state/ducks/toast';
import { missingCaseError } from '../util/missingCaseError'; import { missingCaseError } from '../util/missingCaseError';
import { ToastType } from '../types/Toast';
export type PropsType = { export type PropsType = {
hideToast: () => unknown; hideToast: () => unknown;

View file

@ -49,7 +49,8 @@ import { waitForOnline } from '../../util/waitForOnline';
import * as mapUtil from '../../util/mapUtil'; import * as mapUtil from '../../util/mapUtil';
import { isCallSafe } from '../../util/isCallSafe'; import { isCallSafe } from '../../util/isCallSafe';
import { isDirectConversation } from '../../util/whatTypeOfConversation'; 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'; import type { ShowToastActionType } from './toast';
// State // State

View file

@ -33,7 +33,8 @@ import {
} from './linkPreviews'; } from './linkPreviews';
import { LinkPreviewSourceType } from '../../types/LinkPreview'; import { LinkPreviewSourceType } from '../../types/LinkPreview';
import { RecordingState } from './audioRecorder'; 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 { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';
import { UUID } from '../../types/UUID'; import { UUID } from '../../types/UUID';
import { assignWithNoUnnecessaryAllocation } from '../../util/assignWithNoUnnecessaryAllocation'; import { assignWithNoUnnecessaryAllocation } from '../../util/assignWithNoUnnecessaryAllocation';

View file

@ -104,7 +104,8 @@ import { ReadStatus } from '../../messages/MessageReadStatus';
import { isIncoming, isOutgoing } from '../selectors/message'; import { isIncoming, isOutgoing } from '../selectors/message';
import { sendDeleteForEveryoneMessage } from '../../util/sendDeleteForEveryoneMessage'; import { sendDeleteForEveryoneMessage } from '../../util/sendDeleteForEveryoneMessage';
import type { ShowToastActionType } from './toast'; 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 { isMemberRequestingToJoin } from '../../util/isMemberRequestingToJoin';
import { removePendingMember } from '../../util/removePendingMember'; import { removePendingMember } from '../../util/removePendingMember';
import { denyPendingApprovalRequest } from '../../util/denyPendingApprovalRequest'; import { denyPendingApprovalRequest } from '../../util/denyPendingApprovalRequest';

View file

@ -18,7 +18,8 @@ import {
isVideoTypeSupported, isVideoTypeSupported,
} from '../../util/GoogleChrome'; } from '../../util/GoogleChrome';
import { isTapToView } from '../selectors/message'; 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 { saveAttachmentFromMessage } from './conversations';
import { showStickerPackPreview } from './globalModals'; import { showStickerPackPreview } from './globalModals';
import { useBoundActions } from '../../hooks/useBoundActions'; import { useBoundActions } from '../../hooks/useBoundActions';

View file

@ -7,39 +7,7 @@ import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import type { NoopActionType } from './noop'; import type { NoopActionType } from './noop';
import type { ReplacementValuesType } from '../../types/Util'; import type { ReplacementValuesType } from '../../types/Util';
import { useBoundActions } from '../../hooks/useBoundActions'; import { useBoundActions } from '../../hooks/useBoundActions';
import type { ToastType } from '../../types/Toast';
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',
}
// State // State
export type ToastStateType = { export type ToastStateType = {

View file

@ -23,7 +23,8 @@ import {
UsernameReservationState, UsernameReservationState,
UsernameReservationError, UsernameReservationError,
} from './usernameEnums'; } from './usernameEnums';
import { showToast, ToastType } from './toast'; import { showToast } from './toast';
import { ToastType } from '../../types/Toast';
import type { ToastActionType } from './toast'; import type { ToastActionType } from './toast';
export type UsernameReservationStateType = Readonly<{ export type UsernameReservationStateType = Readonly<{

View file

@ -9,7 +9,8 @@ import type { LocalizerType } from '../../types/Util';
import type { StateType } from '../reducer'; import type { StateType } from '../reducer';
import type { SelectedStoryDataType } from '../ducks/stories'; import type { SelectedStoryDataType } from '../ducks/stories';
import { StoryViewer } from '../../components/StoryViewer'; 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 { getConversationSelector } from '../selectors/conversations';
import { import {
getEmojiSkinTone, getEmojiSkinTone,

View file

@ -17,7 +17,7 @@ import {
UsernameReservationError, UsernameReservationError,
} from '../../../state/ducks/usernameEnums'; } from '../../../state/ducks/usernameEnums';
import { actions } from '../../../state/ducks/username'; import { actions } from '../../../state/ducks/username';
import { ToastType } from '../../../state/ducks/toast'; import { ToastType } from '../../../types/Toast';
import { noopAction } from '../../../state/ducks/noop'; import { noopAction } from '../../../state/ducks/noop';
import { reducer } from '../../../state/reducer'; import { reducer } from '../../../state/reducer';
import { ReserveUsernameError } from '../../../types/Username'; 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 type { ConversationAttributesType } from '../model-types';
import { ToastType } from '../state/ducks/toast'; import { ToastType } from '../types/Toast';
import { import {
isDirectConversation, isDirectConversation,
isGroupV1, isGroupV1,