Files
mattermost-mobile/app/screens/channel_notification_preferences/thread_replies.tsx
Elias Nahum 2fc1386b78 feat: Channel notification preferences (#7160)
* feat: Channel notification preferences

* feedback review

* use button color for the icon
2023-02-24 12:41:36 +02:00

58 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {useIntl} from 'react-intl';
import SettingBlock from '@components/settings/block';
import SettingOption from '@components/settings/option';
import SettingSeparator from '@components/settings/separator';
import {NotificationLevel} from '@constants';
import {t} from '@i18n';
type Props = {
isSelected: boolean;
notifyLevel: NotificationLevel;
onPress: (selected: boolean) => void;
}
type NotifPrefOptions = {
defaultMessage: string;
id: string;
testID: string;
value: string;
}
const THREAD_REPLIES = {id: t('channel_notification_preferences.thread_replies'), defaultMessage: 'Thread replies'};
const NOTIFY_OPTIONS_THREAD: Record<string, NotifPrefOptions> = {
THREAD_REPLIES: {
defaultMessage: 'Notify me about replies to threads Im following in this channel',
id: t('channel_notification_preferences.notification.thread_replies'),
testID: 'channel_notification_preferences.notification.thread_replies',
value: 'thread_replies',
},
};
const NotifyAbout = ({isSelected, notifyLevel, onPress}: Props) => {
const {formatMessage} = useIntl();
if ([NotificationLevel.NONE, NotificationLevel.ALL].includes(notifyLevel)) {
return null;
}
return (
<SettingBlock headerText={THREAD_REPLIES}>
<SettingOption
action={onPress}
label={formatMessage({id: NOTIFY_OPTIONS_THREAD.THREAD_REPLIES.id, defaultMessage: NOTIFY_OPTIONS_THREAD.THREAD_REPLIES.defaultMessage})}
testID={NOTIFY_OPTIONS_THREAD.THREAD_REPLIES.testID}
type='toggle'
selected={isSelected}
/>
<SettingSeparator/>
</SettingBlock>
);
};
export default NotifyAbout;