Improvements to the media editor
This commit is contained in:
@@ -22,7 +22,7 @@ import {
|
||||
GroupCallJoinState,
|
||||
} from '../types/Calling';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import { isAciString } from '../types/ServiceId';
|
||||
import { isAciString } from './isAciString';
|
||||
import { isMe } from './whatTypeOfConversation';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
|
@@ -6,7 +6,7 @@ import type { MessageModel } from '../models/messages';
|
||||
import type { SignalService as Proto } from '../protobuf';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import * as log from '../logging/log';
|
||||
import { normalizeAci } from '../types/ServiceId';
|
||||
import { normalizeAci } from './normalizeAci';
|
||||
import { filter } from './iterables';
|
||||
import { getContactId } from '../messages/helpers';
|
||||
import { getTimestampFromLong } from './timestampLongUtils';
|
||||
|
@@ -15,7 +15,7 @@ import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import dataInterface from '../sql/Client';
|
||||
import { drop } from './drop';
|
||||
import { getAttachmentSignature, isVoiceMessage } from '../types/Attachment';
|
||||
import { isAciString } from '../types/ServiceId';
|
||||
import { isAciString } from './isAciString';
|
||||
import { getMessageIdForLogging } from './idForLogging';
|
||||
import { hasErrors } from '../state/selectors/message';
|
||||
import { isIncoming, isOutgoing } from '../messages/helpers';
|
||||
|
9
ts/util/isAciString.ts
Normal file
9
ts/util/isAciString.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import { isValidUuid } from './isValidUuid';
|
||||
|
||||
export function isAciString(value?: string | null): value is AciString {
|
||||
return isValidUuid(value);
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ConversationType } from '../state/ducks/conversations';
|
||||
import { isAciString } from '../types/ServiceId';
|
||||
import { isAciString } from './isAciString';
|
||||
|
||||
export const isSafetyNumberNotAvailable = (
|
||||
contact?: ConversationType
|
||||
|
@@ -2004,13 +2004,6 @@
|
||||
"updated": "2021-12-10T23:24:03.829Z",
|
||||
"reasonDetail": "Doesn't touch the DOM."
|
||||
},
|
||||
{
|
||||
"rule": "React-useRef",
|
||||
"path": "ts/components/AddCaptionModal.tsx",
|
||||
"line": " const scrollerRef = React.useRef<HTMLDivElement>(null);",
|
||||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2022-10-03T16:06:12.837Z"
|
||||
},
|
||||
{
|
||||
"rule": "React-useRef",
|
||||
"path": "ts/components/AvatarTextEditor.tsx",
|
||||
@@ -2390,6 +2383,13 @@
|
||||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2022-11-11T17:11:07.659Z"
|
||||
},
|
||||
{
|
||||
"rule": "React-useRef",
|
||||
"path": "ts/components/MediaEditor.tsx",
|
||||
"line": " const inputApiRef = useRef<InputApi | undefined>();",
|
||||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2023-09-11T20:19:18.681Z"
|
||||
},
|
||||
{
|
||||
"rule": "React-useRef",
|
||||
"path": "ts/components/MediaQualitySelector.tsx",
|
||||
|
@@ -23,7 +23,7 @@ import {
|
||||
} from '../jobs/conversationJobQueue';
|
||||
import { ReceiptType } from '../types/Receipt';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import { isAciString } from '../types/ServiceId';
|
||||
import { isAciString } from './isAciString';
|
||||
|
||||
export async function markConversationRead(
|
||||
conversationAttrs: ConversationAttributesType,
|
||||
|
42
ts/util/normalizeAci.ts
Normal file
42
ts/util/normalizeAci.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import type { LoggerType } from '../types/Logging';
|
||||
import * as log from '../logging/log';
|
||||
import { isAciString } from './isAciString';
|
||||
|
||||
export function normalizeAci(
|
||||
rawAci: string,
|
||||
context: string,
|
||||
logger?: Pick<LoggerType, 'warn'>
|
||||
): AciString;
|
||||
|
||||
export function normalizeAci(
|
||||
rawAci: string | undefined | null,
|
||||
context: string,
|
||||
logger?: Pick<LoggerType, 'warn'>
|
||||
): AciString | undefined;
|
||||
|
||||
export function normalizeAci(
|
||||
rawAci: string | undefined | null,
|
||||
context: string,
|
||||
logger: Pick<LoggerType, 'warn'> = log
|
||||
): AciString | undefined {
|
||||
if (rawAci == null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = rawAci.toLowerCase();
|
||||
|
||||
if (!isAciString(result)) {
|
||||
logger.warn(
|
||||
`Normalizing invalid serviceId: ${rawAci} to ${result} in context "${context}"`
|
||||
);
|
||||
|
||||
// Cast anyway we don't want to throw here
|
||||
return result as AciString;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
@@ -15,7 +15,7 @@ import {
|
||||
SafetyNumberIdentifierType,
|
||||
SafetyNumberMode,
|
||||
} from '../types/safetyNumber';
|
||||
import { isAciString } from '../types/ServiceId';
|
||||
import { isAciString } from './isAciString';
|
||||
|
||||
const ITERATION_COUNT = 5200;
|
||||
const E164_VERSION = 1;
|
||||
|
Reference in New Issue
Block a user