mattermost-mobile/app/screens/channel_notification_preferences/thread_replies.tsx
Daniel Espino García 0c4a42a06a
Remove tand prevent double tap (#9078)
* Remove the t function and all wrong uses of preventDoubleTap

* Fix existing typo

* Fix tests

* Address comments

* Fix test
2025-08-25 12:03:01 +02:00

66 lines
2.1 KiB
TypeScript
Raw Permalink 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 {defineMessages, 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';
type Props = {
isSelected: boolean;
notifyLevel: NotificationLevel;
onPress: (selected: boolean) => void;
}
type NotifPrefOptions = {
defaultMessage: string;
id: string;
testID: string;
value: string;
}
const messages = defineMessages({
threadReplies: {
id: 'channel_notification_preferences.thread_replies',
defaultMessage: 'Thread replies',
},
threadRepliesDescription: {
id: 'channel_notification_preferences.notification.thread_replies',
defaultMessage: 'Notify me about replies to threads Im following in this channel',
},
});
const THREAD_REPLIES = messages.threadReplies;
const NOTIFY_OPTIONS_THREAD: Record<string, NotifPrefOptions> = {
THREAD_REPLIES: {
...messages.threadRepliesDescription,
testID: 'channel_notification_preferences.notification.thread_replies',
value: 'thread_replies',
},
};
const NotifyAbout = ({isSelected, notifyLevel, onPress}: Props) => {
const {formatMessage} = useIntl();
const hiddenStates: NotificationLevel[] = [NotificationLevel.NONE, NotificationLevel.ALL];
if (hiddenStates.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;