diff --git a/ts/background.ts b/ts/background.ts index 5d2eef1082..180eb0f412 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -870,6 +870,17 @@ export async function startApp(): Promise { await window.storage.remove('remoteBuildExpiration'); } + if (window.isBeforeVersion(lastVersion, '6.22.0-alpha')) { + const formattingWarningShown = window.storage.get( + 'formattingWarningShown', + false + ); + log.info( + `Clearing formattingWarningShown. Previous value was ${formattingWarningShown}` + ); + await window.storage.put('formattingWarningShown', false); + } + if (window.isBeforeVersion(lastVersion, 'v1.29.2-beta.1')) { // Stickers flags await Promise.all([ diff --git a/ts/state/ducks/composer.ts b/ts/state/ducks/composer.ts index 37e8a9e8a3..28730db597 100644 --- a/ts/state/ducks/composer.ts +++ b/ts/state/ducks/composer.ts @@ -18,6 +18,7 @@ import type { } from '../../types/Attachment'; import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions'; import type { DraftBodyRanges } from '../../types/BodyRange'; +import { BodyRange } from '../../types/BodyRange'; import type { LinkPreviewType } from '../../types/message/LinkPreviews'; import type { MessageAttributesType } from '../../model-types.d'; import type { NoopActionType } from './noop'; @@ -431,8 +432,9 @@ async function withPreSendChecks( } try { - if (bodyRanges?.length && !window.storage.get('formattingWarningShown')) { - const sendAnyway = await maybeBlockSendForFormattingModal(bodyRanges); + const hasFormatting = bodyRanges?.some(BodyRange.isFormatting); + if (hasFormatting && !window.storage.get('formattingWarningShown')) { + const sendAnyway = await maybeBlockSendForFormattingModal(); if (!sendAnyway) { dispatch(setComposerDisabledState(conversationId, false)); return; diff --git a/ts/state/selectors/composer.ts b/ts/state/selectors/composer.ts index e4503d08d3..d4a30d84e8 100644 --- a/ts/state/selectors/composer.ts +++ b/ts/state/selectors/composer.ts @@ -27,13 +27,16 @@ export const getQuotedMessageSelector = createSelector( export const getIsFormattingFlagEnabled = createSelector( getRemoteConfig, remoteConfig => { - return isRemoteConfigFlagEnabled(remoteConfig, 'desktop.internalUser'); + return isRemoteConfigFlagEnabled(remoteConfig, 'desktop.textFormatting'); } ); export const getIsFormattingSpoilersFlagEnabled = createSelector( getRemoteConfig, remoteConfig => { - return isRemoteConfigFlagEnabled(remoteConfig, 'desktop.internalUser'); + return isRemoteConfigFlagEnabled( + remoteConfig, + 'desktop.textFormatting.spoilerSend' + ); } ); diff --git a/ts/util/createIPCEvents.ts b/ts/util/createIPCEvents.ts index 58dae69e75..53d11c6530 100644 --- a/ts/util/createIPCEvents.ts +++ b/ts/util/createIPCEvents.ts @@ -414,7 +414,7 @@ export function createIPCEvents( return window.IPC.setAutoLaunch(value); }, - isFormattingFlagEnabled: () => isEnabled('desktop.internalUser'), + isFormattingFlagEnabled: () => isEnabled('desktop.textFormatting'), isPhoneNumberSharingEnabled: () => isPhoneNumberSharingEnabled(), isPrimary: () => window.textsecure.storage.user.getDeviceId() === 1, shouldShowStoriesSettings: () => getStoriesAvailable(), diff --git a/ts/util/maybeBlockSendForFormattingModal.ts b/ts/util/maybeBlockSendForFormattingModal.ts index 31c902c52b..79e340acaa 100644 --- a/ts/util/maybeBlockSendForFormattingModal.ts +++ b/ts/util/maybeBlockSendForFormattingModal.ts @@ -1,17 +1,9 @@ // Copyright 2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -import type { DraftBodyRanges } from '../types/BodyRange'; -import { BodyRange } from '../types/BodyRange'; import { explodePromise } from './explodePromise'; -export async function maybeBlockSendForFormattingModal( - bodyRanges: DraftBodyRanges -): Promise { - if (!bodyRanges.some(BodyRange.isFormatting)) { - return true; - } - +export async function maybeBlockSendForFormattingModal(): Promise { const explodedPromise = explodePromise(); window.reduxActions.globalModals.showFormattingWarningModal(explodedPromise); return explodedPromise.promise;