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
53 changed files with 342 additions and 258 deletions
+2 -1
View File
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import type { ReadonlyDeep } from 'type-fest';
import type {
EmbeddedContactType,
@@ -21,7 +22,7 @@ import {
import type { LocalizerType } from '../../types/Util';
export type Props = {
contact: EmbeddedContactType;
contact: ReadonlyDeep<EmbeddedContactType>;
hasSignalAccount: boolean;
i18n: LocalizerType;
onSendMessage: () => void;
@@ -3,6 +3,7 @@
import React from 'react';
import classNames from 'classnames';
import type { ReadonlyDeep } from 'type-fest';
import type { EmbeddedContactType } from '../../types/EmbeddedContact';
@@ -14,7 +15,7 @@ import {
} from './contactUtil';
export type Props = {
contact: EmbeddedContactType;
contact: ReadonlyDeep<EmbeddedContactType>;
i18n: LocalizerType;
isIncoming: boolean;
withContentAbove: boolean;
+3 -2
View File
@@ -4,6 +4,7 @@
import type { ReactElement, ReactNode } from 'react';
import React, { useState } from 'react';
import { get } from 'lodash';
import type { ReadonlyDeep } from 'type-fest';
import * as log from '../../logging/log';
import { I18n } from '../I18n';
@@ -27,7 +28,7 @@ import { renderChange } from '../../groupChange';
import { Modal } from '../Modal';
import { ConfirmationDialog } from '../ConfirmationDialog';
export type PropsDataType = {
export type PropsDataType = ReadonlyDeep<{
areWeAdmin: boolean;
change: GroupV2ChangeType;
conversationId: string;
@@ -39,7 +40,7 @@ export type PropsDataType = {
groupName?: string;
ourAci: AciString | undefined;
ourPni: PniString | undefined;
};
}>;
export type PropsActionsType = {
blockGroupLinkRequests: (
+2 -1
View File
@@ -16,6 +16,7 @@ import getDirection from 'direction';
import { drop, groupBy, noop, orderBy, take, unescape } from 'lodash';
import { Manager, Popper, Reference } from 'react-popper';
import type { PreventOverflowModifier } from '@popperjs/core/lib/modifiers/preventOverflow';
import type { ReadonlyDeep } from 'type-fest';
import type {
ConversationType,
@@ -229,7 +230,7 @@ export type PropsData = {
timestamp: number;
receivedAtMS?: number;
status?: MessageStatusType;
contact?: EmbeddedContactType;
contact?: ReadonlyDeep<EmbeddedContactType>;
author: Pick<
ConversationType,
| 'acceptedMessageRequest'
+4 -3
View File
@@ -3,6 +3,7 @@
import React from 'react';
import classNames from 'classnames';
import type { ReadonlyDeep } from 'type-fest';
import { Avatar, AvatarBlur } from '../Avatar';
import { Spinner } from '../Spinner';
@@ -18,7 +19,7 @@ export function renderAvatar({
size,
direction,
}: {
contact: EmbeddedContactType;
contact: ReadonlyDeep<EmbeddedContactType>;
i18n: LocalizerType;
size: 28 | 52 | 80;
direction?: 'outgoing' | 'incoming';
@@ -65,7 +66,7 @@ export function renderName({
isIncoming,
module,
}: {
contact: EmbeddedContactType;
contact: ReadonlyDeep<EmbeddedContactType>;
isIncoming: boolean;
module: string;
}): JSX.Element {
@@ -86,7 +87,7 @@ export function renderContactShorthand({
isIncoming,
module,
}: {
contact: EmbeddedContactType;
contact: ReadonlyDeep<EmbeddedContactType>;
isIncoming: boolean;
module: string;
}): JSX.Element {
@@ -1,11 +1,11 @@
// Copyright 2018 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { MessageAttributesType } from '../../../../model-types.d';
import type { ReadonlyMessageAttributesType } from '../../../../model-types.d';
import type { AttachmentType } from '../../../../types/Attachment';
export type ItemClickEvent = {
message: Pick<MessageAttributesType, 'sent_at'>;
message: Pick<ReadonlyMessageAttributesType, 'sent_at'>;
attachment: AttachmentType;
index: number;
type: 'media' | 'documents';