2021-08-05 12:35:33 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import React, { memo } from 'react';
|
2021-08-05 12:35:33 +00:00
|
|
|
import { ConversationNotificationsSettings } from '../../components/conversation/conversation-details/ConversationNotificationsSettings';
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { getConversationByIdSelector } from '../selectors/conversations';
|
|
|
|
import { strictAssert } from '../../util/assert';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
2021-08-05 12:35:33 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export type SmartConversationNotificationsSettingsProps = {
|
2021-08-05 12:35:33 +00:00
|
|
|
conversationId: string;
|
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartConversationNotificationsSettings = memo(
|
|
|
|
function SmartConversationNotificationsSettings({
|
|
|
|
conversationId,
|
|
|
|
}: SmartConversationNotificationsSettingsProps) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const conversationSelector = useSelector(getConversationByIdSelector);
|
|
|
|
const { setMuteExpiration, setDontNotifyForMentionsIfMuted } =
|
|
|
|
useConversationsActions();
|
|
|
|
const conversation = conversationSelector(conversationId);
|
|
|
|
strictAssert(conversation, 'Expected a conversation to be found');
|
|
|
|
const {
|
|
|
|
type: conversationType,
|
|
|
|
dontNotifyForMentionsIfMuted,
|
|
|
|
muteExpiresAt,
|
|
|
|
} = conversation;
|
|
|
|
return (
|
|
|
|
<ConversationNotificationsSettings
|
|
|
|
id={conversationId}
|
|
|
|
conversationType={conversationType}
|
|
|
|
dontNotifyForMentionsIfMuted={dontNotifyForMentionsIfMuted ?? false}
|
|
|
|
i18n={i18n}
|
|
|
|
muteExpiresAt={muteExpiresAt}
|
|
|
|
setMuteExpiration={setMuteExpiration}
|
|
|
|
setDontNotifyForMentionsIfMuted={setDontNotifyForMentionsIfMuted}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-08-05 12:35:33 +00:00
|
|
|
);
|