Skip to content

Commit

Permalink
Enable formatting for all users
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jun 14, 2023
1 parent d2b0641 commit 23b058f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
11 changes: 11 additions & 0 deletions ts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,17 @@ export async function startApp(): Promise<void> {
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([
Expand Down
6 changes: 4 additions & 2 deletions ts/state/ducks/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions ts/state/selectors/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
);
2 changes: 1 addition & 1 deletion ts/util/createIPCEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 1 addition & 9 deletions ts/util/maybeBlockSendForFormattingModal.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
if (!bodyRanges.some(BodyRange.isFormatting)) {
return true;
}

export async function maybeBlockSendForFormattingModal(): Promise<boolean> {
const explodedPromise = explodePromise<boolean>();
window.reduxActions.globalModals.showFormattingWarningModal(explodedPromise);
return explodedPromise.promise;
Expand Down

0 comments on commit 23b058f

Please sign in to comment.