2021-08-05 12:35:33 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { ConversationNotificationsSettings } from '../../components/conversation/conversation-details/ConversationNotificationsSettings';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-08-05 12:35:33 +00:00
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { getConversationByIdSelector } from '../selectors/conversations';
|
|
|
|
import { strictAssert } from '../../util/assert';
|
2022-12-06 17:31:44 +00:00
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-08-05 12:35:33 +00:00
|
|
|
|
|
|
|
export type OwnProps = {
|
|
|
|
conversationId: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (state: StateType, props: OwnProps) => {
|
2022-12-06 17:31:44 +00:00
|
|
|
const { conversationId } = props;
|
2021-08-05 12:35:33 +00:00
|
|
|
|
|
|
|
const conversationSelector = getConversationByIdSelector(state);
|
|
|
|
const conversation = conversationSelector(conversationId);
|
|
|
|
strictAssert(conversation, 'Expected a conversation to be found');
|
|
|
|
|
|
|
|
return {
|
2022-12-06 17:31:44 +00:00
|
|
|
id: conversationId,
|
2021-08-05 12:35:33 +00:00
|
|
|
conversationType: conversation.type,
|
|
|
|
dontNotifyForMentionsIfMuted: Boolean(
|
|
|
|
conversation.dontNotifyForMentionsIfMuted
|
|
|
|
),
|
|
|
|
i18n: getIntl(state),
|
|
|
|
muteExpiresAt: conversation.muteExpiresAt,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-06 17:31:44 +00:00
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
2021-08-05 12:35:33 +00:00
|
|
|
|
|
|
|
export const SmartConversationNotificationsSettings = smart(
|
|
|
|
ConversationNotificationsSettings
|
|
|
|
);
|