Rename ContactType to EmbeddedContactType

This commit is contained in:
Fedor Indutny 2021-08-19 18:56:39 -07:00 committed by GitHub
parent 017a0fa807
commit fe040a2873
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 46 additions and 42 deletions

View File

@ -137,7 +137,7 @@ const searchSelectors = require('../../ts/state/selectors/search');
// Types
const AttachmentType = require('../../ts/types/Attachment');
const VisualAttachment = require('./types/visual_attachment');
const Contact = require('../../ts/types/Contact');
const EmbeddedContact = require('../../ts/types/EmbeddedContact');
const Conversation = require('./types/conversation');
const Errors = require('../../ts/types/errors');
const MediaGalleryMessage = require('../../ts/components/conversation/media-gallery/types/Message');
@ -429,7 +429,7 @@ exports.setup = (options = {}) => {
const Types = {
Attachment: AttachmentType,
Contact,
EmbeddedContact,
Conversation,
Errors,
Message: MessageType,

View File

@ -8,7 +8,7 @@ import { boolean } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import { ContactDetail, Props } from './ContactDetail';
import { AddressType, ContactFormType } from '../../types/Contact';
import { AddressType, ContactFormType } from '../../types/EmbeddedContact';
import { setup as setupI18n } from '../../../js/modules/i18n';
import enMessages from '../../../_locales/en/messages.json';
import { IMAGE_GIF } from '../../types/MIME';

View File

@ -6,11 +6,11 @@ import React from 'react';
import {
AddressType,
ContactFormType,
ContactType,
EmbeddedContactType,
Email,
Phone,
PostalAddress,
} from '../../types/Contact';
} from '../../types/EmbeddedContact';
import { missingCaseError } from '../../util/missingCaseError';
import {
@ -22,7 +22,7 @@ import {
import { LocalizerType } from '../../types/Util';
export type Props = {
contact: ContactType;
contact: EmbeddedContactType;
hasSignalAccount: boolean;
i18n: LocalizerType;
onSendMessage: () => void;

View File

@ -10,7 +10,7 @@ import { storiesOf } from '@storybook/react';
import { EmbeddedContact, Props } from './EmbeddedContact';
import { setup as setupI18n } from '../../../js/modules/i18n';
import enMessages from '../../../_locales/en/messages.json';
import { ContactFormType } from '../../types/Contact';
import { ContactFormType } from '../../types/EmbeddedContact';
import { IMAGE_GIF } from '../../types/MIME';
const i18n = setupI18n('en', enMessages);

View File

@ -4,7 +4,7 @@
import React from 'react';
import classNames from 'classnames';
import { ContactType } from '../../types/Contact';
import { EmbeddedContactType } from '../../types/EmbeddedContact';
import { LocalizerType } from '../../types/Util';
import {
@ -14,7 +14,7 @@ import {
} from './_contactUtil';
export type Props = {
contact: ContactType;
contact: EmbeddedContactType;
i18n: LocalizerType;
isIncoming: boolean;
withContentAbove: boolean;

View File

@ -49,7 +49,7 @@ import {
isVideo,
isGIF,
} from '../../types/Attachment';
import { ContactType } from '../../types/Contact';
import { EmbeddedContactType } from '../../types/EmbeddedContact';
import { getIncrement } from '../../util/timer';
import { isFileDangerous } from '../../util/isFileDangerous';
@ -129,7 +129,7 @@ export type PropsData = {
direction: DirectionType;
timestamp: number;
status?: MessageStatusType;
contact?: ContactType;
contact?: EmbeddedContactType;
author: Pick<
ConversationType,
| 'acceptedMessageRequest'
@ -216,7 +216,7 @@ export type PropsActions = {
openConversation: (conversationId: string, messageId?: string) => void;
showContactDetail: (options: {
contact: ContactType;
contact: EmbeddedContactType;
signalAccount?: string;
}) => void;
showContactModal: (contactId: string) => void;

View File

@ -9,7 +9,7 @@ import { Spinner } from '../Spinner';
import { LocalizerType } from '../../types/Util';
import { AvatarColors } from '../../types/Colors';
import { ContactType, getName } from '../../types/Contact';
import { EmbeddedContactType, getName } from '../../types/EmbeddedContact';
// This file starts with _ to keep it from showing up in the StyleGuide.
@ -19,7 +19,7 @@ export function renderAvatar({
size,
direction,
}: {
contact: ContactType;
contact: EmbeddedContactType;
i18n: LocalizerType;
size: 28 | 52 | 80;
direction?: 'outgoing' | 'incoming';
@ -65,7 +65,7 @@ export function renderName({
isIncoming,
module,
}: {
contact: ContactType;
contact: EmbeddedContactType;
isIncoming: boolean;
module: string;
}): JSX.Element {
@ -86,7 +86,7 @@ export function renderContactShorthand({
isIncoming,
module,
}: {
contact: ContactType;
contact: EmbeddedContactType;
isIncoming: boolean;
module: string;
}): JSX.Element {

4
ts/model-types.d.ts vendored
View File

@ -23,7 +23,7 @@ import {
import { GroupNameCollisionsWithIdsByTitle } from './util/groupMemberNameCollisions';
import { ConversationColorType } from './types/Colors';
import { AttachmentType, ThumbnailType } from './types/Attachment';
import { ContactType } from './types/Contact';
import { EmbeddedContactType } from './types/EmbeddedContact';
import { SignalService as Proto } from './protobuf';
import { AvatarDataType } from './types/Avatar';
@ -156,7 +156,7 @@ export type MessageAttributesType = {
};
sent_at: number;
unidentifiedDeliveries?: Array<string>;
contact?: Array<ContactType>;
contact?: Array<EmbeddedContactType>;
conversationId: string;
reaction?: WhatIsThis;

View File

@ -90,7 +90,7 @@ const FIXMEU8 = Uint8Array;
window.Whisper = window.Whisper || {};
const { Services, Util } = window.Signal;
const { Contact, Message } = window.Signal.Types;
const { EmbeddedContact, Message } = window.Signal.Types;
const {
deleteAttachmentData,
doesAttachmentExist,
@ -3170,7 +3170,7 @@ export class ConversationModel extends window.Backbone
async makeQuote(
quotedMessage: typeof window.Whisper.MessageType
): Promise<QuotedMessageType> {
const { getName } = Contact;
const { getName } = EmbeddedContact;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const contact = quotedMessage.getContact()!;
const attachments = quotedMessage.get('attachments');

View File

@ -129,7 +129,7 @@ const {
Message: TypedMessage,
Attachment,
MIME,
Contact,
EmbeddedContact,
Errors,
} = window.Signal.Types;
const {
@ -678,7 +678,8 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const contacts = this.get('contact');
if (contacts && contacts.length) {
return {
text: Contact.getName(contacts[0]) || window.i18n('unknownContact'),
text:
EmbeddedContact.getName(contacts[0]) || window.i18n('unknownContact'),
emoji: '👤',
};
}

View File

@ -38,7 +38,10 @@ import { QuotedAttachmentType } from '../../components/conversation/Quote';
import { getDomain, isStickerPack } from '../../types/LinkPreview';
import { ContactType, contactSelector } from '../../types/Contact';
import {
EmbeddedContactType,
embeddedContactSelector,
} from '../../types/EmbeddedContact';
import { AssertProps, BodyRangesType } from '../../types/Util';
import { LinkPreviewType } from '../../types/message/LinkPreviews';
import { ConversationColors } from '../../types/Colors';
@ -1260,7 +1263,7 @@ export function getPropsForEmbeddedContact(
message: MessageAttributesType,
regionCode: string,
accountSelector: (identifier?: string) => boolean
): ContactType | undefined {
): EmbeddedContactType | undefined {
const contacts = message.contact;
if (!contacts || !contacts.length) {
return undefined;
@ -1270,7 +1273,7 @@ export function getPropsForEmbeddedContact(
const numbers = firstContact?.number;
const firstNumber = numbers && numbers[0] ? numbers[0].value : undefined;
return contactSelector(firstContact, {
return embeddedContactSelector(firstContact, {
regionCode,
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,

View File

@ -4,7 +4,7 @@
import { assert } from 'chai';
import { IMAGE_GIF } from '../../types/MIME';
import { contactSelector, getName } from '../../types/Contact';
import { embeddedContactSelector, getName } from '../../types/EmbeddedContact';
describe('Contact', () => {
describe('getName', () => {
@ -65,7 +65,7 @@ describe('Contact', () => {
assert.strictEqual(actual, expected);
});
});
describe('contactSelector', () => {
describe('embeddedContactSelector', () => {
const regionCode = '1';
const firstNumber = '+1202555000';
const isNumberOnSignal = false;
@ -99,7 +99,7 @@ describe('Contact', () => {
isNumberOnSignal,
number: undefined,
};
const actual = contactSelector(contact, {
const actual = embeddedContactSelector(contact, {
regionCode,
firstNumber,
isNumberOnSignal,
@ -143,7 +143,7 @@ describe('Contact', () => {
isNumberOnSignal,
number: undefined,
};
const actual = contactSelector(contact, {
const actual = embeddedContactSelector(contact, {
regionCode,
firstNumber,
isNumberOnSignal,
@ -186,7 +186,7 @@ describe('Contact', () => {
isNumberOnSignal: true,
number: undefined,
};
const actual = contactSelector(contact, {
const actual = embeddedContactSelector(contact, {
regionCode,
firstNumber,
isNumberOnSignal: true,

View File

@ -4,7 +4,7 @@
import { format as formatPhoneNumber } from './PhoneNumber';
import { AttachmentType } from './Attachment';
export type ContactType = {
export type EmbeddedContactType = {
name?: Name;
number?: Array<Phone>;
email?: Array<Email>;
@ -68,15 +68,15 @@ type Avatar = {
isProfile: boolean;
};
export function contactSelector(
contact: ContactType,
export function embeddedContactSelector(
contact: EmbeddedContactType,
options: {
regionCode: string;
firstNumber?: string;
isNumberOnSignal?: boolean;
getAbsoluteAttachmentPath: (path: string) => string;
}
): ContactType {
): EmbeddedContactType {
const {
getAbsoluteAttachmentPath,
firstNumber,
@ -117,7 +117,7 @@ export function contactSelector(
};
}
export function getName(contact: ContactType): string | undefined {
export function getName(contact: EmbeddedContactType): string | undefined {
const { name, organization } = contact;
const displayName = (name && name.displayName) || undefined;
const givenName = (name && name.givenName) || undefined;

View File

@ -4,7 +4,7 @@
/* eslint-disable camelcase */
import { AttachmentType } from './Attachment';
import { ContactType } from './Contact';
import { EmbeddedContactType } from './EmbeddedContact';
import { IndexableBoolean, IndexablePresence } from './IndexedDB';
export type Message = (
@ -110,7 +110,7 @@ type MessageSchemaVersion5 = Partial<
type MessageSchemaVersion6 = Partial<
Readonly<{
contact: Array<ContactType>;
contact: Array<EmbeddedContactType>;
}>
>;

View File

@ -65,7 +65,7 @@ import { ReadStatus } from '../messages/MessageReadStatus';
import { markViewed } from '../services/MessageUpdater';
import { viewedReceiptsJobQueue } from '../jobs/viewedReceiptsJobQueue';
import { viewSyncJobQueue } from '../jobs/viewSyncJobQueue';
import type { ContactType } from '../types/Contact';
import type { EmbeddedContactType } from '../types/EmbeddedContact';
import type { WhatIsThis } from '../window.d';
type AttachmentOptions = {
@ -845,7 +845,7 @@ Whisper.ConversationView = Whisper.View.extend({
this.openConversation(conversationId, messageId);
};
const showContactDetail = (options: {
contact: ContactType;
contact: EmbeddedContactType;
signalAccount?: string;
}) => {
this.showContactDetail(options);
@ -3486,7 +3486,7 @@ Whisper.ConversationView = Whisper.View.extend({
contact,
signalAccount,
}: {
contact: ContactType;
contact: EmbeddedContactType;
signalAccount?: string;
}) {
const view = new Whisper.ReactWrapperView({

4
ts/window.d.ts vendored
View File

@ -36,7 +36,7 @@ import * as zkgroup from './util/zkgroup';
import { LocalizerType, BodyRangesType, BodyRangeType } from './types/Util';
import * as Attachment from './types/Attachment';
import * as MIME from './types/MIME';
import * as Contact from './types/Contact';
import * as EmbeddedContact from './types/EmbeddedContact';
import * as Errors from './types/errors';
import { ConversationController } from './ConversationController';
import { ReduxActions } from './state/types';
@ -359,7 +359,7 @@ declare global {
Types: {
Attachment: typeof Attachment;
MIME: typeof MIME;
Contact: typeof Contact;
EmbeddedContact: typeof EmbeddedContact;
Conversation: {
computeHash: (data: string) => Promise<string>;
deleteExternalFiles: (