Make most message attribute uses readonly

Co-authored-by: Jamie Kyle <jamie@signal.org>
This commit is contained in:
Fedor Indutny 2024-07-24 13:14:11 -07:00 committed by GitHub
parent c619a7b6fd
commit 3555ccc629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 342 additions and 258 deletions

View file

@ -2,10 +2,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { isNumber, sortBy } from 'lodash';
import type { ReadonlyDeep } from 'type-fest';
import { strictAssert } from './assert';
import type { EditHistoryType, MessageAttributesType } from '../model-types';
import type {
EditHistoryType,
MessageAttributesType,
ReadonlyMessageAttributesType,
} from '../model-types';
import type { LoggerType } from '../types/Logging';
// The tricky bit for this function is if we are on our second+ attempt to send a given
@ -14,7 +19,7 @@ export function getTargetOfThisEditTimestamp({
message,
targetTimestamp,
}: {
message: MessageAttributesType;
message: ReadonlyMessageAttributesType;
targetTimestamp: number;
}): number {
const { timestamp: originalTimestamp, editHistory } = message;
@ -27,7 +32,7 @@ export function getTargetOfThisEditTimestamp({
});
const mostRecent = sortBy(
sentItems,
(item: EditHistoryType) => item.timestamp
(item: ReadonlyDeep<EditHistoryType>) => item.timestamp
);
const { length } = mostRecent;