ConversationView: Move setPin to redux

This commit is contained in:
Scott Nonnenberg 2022-12-06 17:00:02 -08:00 committed by GitHub
parent e9b7a74b32
commit ff6750e4fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 135 additions and 86 deletions

View file

@ -39,6 +39,86 @@ InvalidToast.args = {
},
};
export const AddingUserToGroup = Template.bind({});
AddingUserToGroup.args = {
toast: {
toastType: ToastType.AddingUserToGroup,
parameters: {
contact: 'Sam Mirete',
},
},
};
export const CannotStartGroupCall = Template.bind({});
CannotStartGroupCall.args = {
toast: {
toastType: ToastType.CannotStartGroupCall,
},
};
export const CopiedUsername = Template.bind({});
CopiedUsername.args = {
toast: {
toastType: ToastType.CopiedUsername,
},
};
export const CopiedUsernameLink = Template.bind({});
CopiedUsernameLink.args = {
toast: {
toastType: ToastType.CopiedUsernameLink,
},
};
export const DeleteForEveryoneFailed = Template.bind({});
DeleteForEveryoneFailed.args = {
toast: {
toastType: ToastType.DeleteForEveryoneFailed,
},
};
export const Error = Template.bind({});
Error.args = {
toast: {
toastType: ToastType.Error,
},
};
export const FailedToDeleteUsername = Template.bind({});
FailedToDeleteUsername.args = {
toast: {
toastType: ToastType.FailedToDeleteUsername,
},
};
export const MessageBodyTooLong = Template.bind({});
MessageBodyTooLong.args = {
toast: {
toastType: ToastType.MessageBodyTooLong,
},
};
export const PinnedConversationsFull = Template.bind({});
PinnedConversationsFull.args = {
toast: {
toastType: ToastType.PinnedConversationsFull,
},
};
export const StoryMuted = Template.bind({});
StoryMuted.args = {
toast: {
toastType: ToastType.StoryMuted,
},
};
export const ReportedSpamAndBlocked = Template.bind({});
ReportedSpamAndBlocked.args = {
toast: {
toastType: ToastType.ReportedSpamAndBlocked,
},
};
export const StoryReact = Template.bind({});
StoryReact.args = {
toast: {
@ -53,10 +133,10 @@ StoryReply.args = {
},
};
export const MessageBodyTooLong = Template.bind({});
MessageBodyTooLong.args = {
export const StoryVideoError = Template.bind({});
StoryVideoError.args = {
toast: {
toastType: ToastType.MessageBodyTooLong,
toastType: ToastType.StoryVideoError,
},
};
@ -74,16 +154,13 @@ StoryVideoUnsupported.args = {
},
};
export const StoryVideoError = Template.bind({});
StoryVideoError.args = {
export const UserAddedToGroup = Template.bind({});
UserAddedToGroup.args = {
toast: {
toastType: ToastType.StoryVideoError,
},
};
export const ReportedSpamAndBlocked = Template.bind({});
ReportedSpamAndBlocked.args = {
toast: {
toastType: ToastType.ReportedSpamAndBlocked,
toastType: ToastType.UserAddedToGroup,
parameters: {
contact: 'Sam Mirete',
group: 'Hike Group 🏔',
},
},
};

View file

@ -105,6 +105,10 @@ export function ToastManager({
);
}
if (toastType === ToastType.PinnedConversationsFull) {
return <Toast onClose={hideToast}>{i18n('pinnedConversationsFull')}</Toast>;
}
if (toastType === ToastType.StoryMuted) {
return (
<Toast onClose={hideToast} timeout={SHORT_TIMEOUT}>

View file

@ -1,28 +0,0 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { action } from '@storybook/addon-actions';
import { ToastPinnedConversationsFull } from './ToastPinnedConversationsFull';
import { setupI18n } from '../util/setupI18n';
import enMessages from '../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
const defaultProps = {
i18n,
onClose: action('onClose'),
};
export default {
title: 'Components/ToastPinnedConversationsFull',
};
export const _ToastPinnedConversationsFull = (): JSX.Element => (
<ToastPinnedConversationsFull {...defaultProps} />
);
_ToastPinnedConversationsFull.story = {
name: 'ToastPinnedConversationsFull',
};

View file

@ -1,18 +0,0 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import type { LocalizerType } from '../types/Util';
import { Toast } from './Toast';
type PropsType = {
i18n: LocalizerType;
onClose: () => unknown;
};
export function ToastPinnedConversationsFull({
i18n,
onClose,
}: PropsType): JSX.Element {
return <Toast onClose={onClose}>{i18n('pinnedConversationsFull')}</Toast>;
}

View file

@ -55,8 +55,8 @@ const commonProps = {
onArchive: action('onArchive'),
onMarkUnread: action('onMarkUnread'),
onMoveToInbox: action('onMoveToInbox'),
onSetPin: action('onSetPin'),
setMuteExpiration: action('onSetMuteNotifications'),
setPinned: action('setPinned'),
viewUserStories: action('viewUserStories'),
};

View file

@ -84,7 +84,6 @@ export type PropsActionsType = {
onSearchInConversation: () => void;
onOutgoingAudioCallInConversation: (conversationId: string) => void;
onOutgoingVideoCallInConversation: (conversationId: string) => void;
onSetPin: (value: boolean) => void;
onShowConversationDetails: () => void;
onShowAllMedia: () => void;
@ -99,6 +98,7 @@ export type PropsActionsType = {
conversationId: string,
seconds: DurationInSeconds
) => void;
setPinned: (conversationId: string, value: boolean) => void;
viewUserStories: ViewUserStoriesActionCreatorType;
};
@ -349,12 +349,12 @@ export class ConversationHeader extends React.Component<PropsType, StateType> {
onArchive,
onMarkUnread,
onMoveToInbox,
onSetPin,
onShowAllMedia,
onShowConversationDetails,
onShowGroupMembers,
setDisappearingMessages,
setMuteExpiration,
setPinned,
type,
} = this.props;
@ -502,11 +502,11 @@ export class ConversationHeader extends React.Component<PropsType, StateType> {
{i18n('deleteMessages')}
</MenuItem>
{isPinned ? (
<MenuItem onClick={() => onSetPin(false)}>
<MenuItem onClick={() => setPinned(id, false)}>
{i18n('unpinConversation')}
</MenuItem>
) : (
<MenuItem onClick={() => onSetPin(true)}>
<MenuItem onClick={() => setPinned(id, true)}>
{i18n('pinConversation')}
</MenuItem>
)}