ConversationView: Move call/mute functions into redux

This commit is contained in:
Scott Nonnenberg 2022-12-06 09:31:44 -08:00 committed by GitHub
parent 8fe51cc854
commit 92a512a16d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 353 additions and 287 deletions

View file

@ -7,36 +7,31 @@ import type { StateType } from '../reducer';
import { getIntl } from '../selectors/user';
import { getConversationByIdSelector } from '../selectors/conversations';
import { strictAssert } from '../../util/assert';
import { mapDispatchToProps } from '../actions';
export type OwnProps = {
conversationId: string;
setDontNotifyForMentionsIfMuted: (
dontNotifyForMentionsIfMuted: boolean
) => unknown;
setMuteExpiration: (muteExpiresAt: undefined | number) => unknown;
};
const mapStateToProps = (state: StateType, props: OwnProps) => {
const { conversationId, setDontNotifyForMentionsIfMuted, setMuteExpiration } =
props;
const { conversationId } = props;
const conversationSelector = getConversationByIdSelector(state);
const conversation = conversationSelector(conversationId);
strictAssert(conversation, 'Expected a conversation to be found');
return {
id: conversationId,
conversationType: conversation.type,
dontNotifyForMentionsIfMuted: Boolean(
conversation.dontNotifyForMentionsIfMuted
),
i18n: getIntl(state),
muteExpiresAt: conversation.muteExpiresAt,
setDontNotifyForMentionsIfMuted,
setMuteExpiration,
};
};
const smart = connect(mapStateToProps, {});
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartConversationNotificationsSettings = smart(
ConversationNotificationsSettings