diff --git a/app/components/post_draft/draft_input/index.tsx b/app/components/post_draft/draft_input/index.tsx index cb3c5c77c..fdabc65f1 100644 --- a/app/components/post_draft/draft_input/index.tsx +++ b/app/components/post_draft/draft_input/index.tsx @@ -147,28 +147,28 @@ export default function DraftInput({ const sendActionTestID = `${testID}.send_action`; const style = getStyleSheet(theme); - const persistenNotificationsEnabled = postPriority.persistent_notifications && postPriority.priority === PostPriorityType.URGENT; + const persistentNotificationsEnabled = postPriority.persistent_notifications && postPriority.priority === PostPriorityType.URGENT; const {noMentionsError, mentionsList} = useMemo(() => { let error = false; let mentions: string[] = []; if ( channelType !== General.DM_CHANNEL && - persistenNotificationsEnabled + persistentNotificationsEnabled ) { mentions = (value.match(MENTIONS_REGEX) || []); error = mentions.length === 0; } return {noMentionsError: error, mentionsList: mentions}; - }, [channelType, persistenNotificationsEnabled, value]); + }, [channelType, persistentNotificationsEnabled, value]); const handleSendMessage = useCallback(async () => { - if (persistenNotificationsEnabled) { - persistentNotificationsConfirmation(serverUrl, value, mentionsList, intl, sendMessage, persistentNotificationMaxRecipients, persistentNotificationInterval); + if (persistentNotificationsEnabled) { + persistentNotificationsConfirmation(serverUrl, value, mentionsList, intl, sendMessage, persistentNotificationMaxRecipients, persistentNotificationInterval, channelType); } else { sendMessage(); } - }, [serverUrl, mentionsList, persistenNotificationsEnabled, persistentNotificationMaxRecipients, sendMessage, value]); + }, [serverUrl, mentionsList, persistentNotificationsEnabled, persistentNotificationMaxRecipients, sendMessage, value, channelType]); const sendActionDisabled = !canSend || noMentionsError; diff --git a/app/utils/post/index.ts b/app/utils/post/index.ts index 830a23cfb..a155ea174 100644 --- a/app/utils/post/index.ts +++ b/app/utils/post/index.ts @@ -4,7 +4,7 @@ import {Alert, type AlertButton} from 'react-native'; import {getUsersCountFromMentions} from '@actions/local/post'; -import {Post} from '@constants'; +import {General, Post} from '@constants'; import {SPECIAL_MENTIONS_REGEX} from '@constants/autocomplete'; import {POST_TIME_TO_FAIL} from '@constants/post'; import {DEFAULT_LOCALE} from '@i18n'; @@ -104,7 +104,7 @@ export function hasSpecialMentions(message: string): boolean { return result; } -export async function persistentNotificationsConfirmation(serverUrl: string, value: string, mentionsList: string[], intl: IntlShape, sendMessage: () => void, persistentNotificationMaxRecipients: number, persistentNotificationInterval: number) { +export async function persistentNotificationsConfirmation(serverUrl: string, value: string, mentionsList: string[], intl: IntlShape, sendMessage: () => void, persistentNotificationMaxRecipients: number, persistentNotificationInterval: number, channelType?: ChannelType) { let title = ''; let description = ''; let buttons: AlertButton[] = [{ @@ -136,7 +136,7 @@ export async function persistentNotificationsConfirmation(serverUrl: string, val max: persistentNotificationMaxRecipients, count: mentionsList.length, }); - } else if (usersCount === 0) { + } else if (usersCount === 0 && channelType !== General.DM_CHANNEL) { title = intl.formatMessage({ id: 'persistent_notifications.error.no_mentions.title', defaultMessage: 'Recipients must be @mentioned',