Update Backbone types: attributes is T - and fix failing type checks
This commit is contained in:
parent
c65a7d0a14
commit
b8234765bf
11 changed files with 57 additions and 24 deletions
|
@ -1,8 +1,8 @@
|
||||||
diff --git a/node_modules/@types/backbone/index.d.ts b/node_modules/@types/backbone/index.d.ts
|
diff --git a/node_modules/@types/backbone/index.d.ts b/node_modules/@types/backbone/index.d.ts
|
||||||
index a172230..b85ab4c 100644
|
index a172230..6f6de9f 100644
|
||||||
--- a/node_modules/@types/backbone/index.d.ts
|
--- a/node_modules/@types/backbone/index.d.ts
|
||||||
+++ b/node_modules/@types/backbone/index.d.ts
|
+++ b/node_modules/@types/backbone/index.d.ts
|
||||||
@@ -218,7 +218,7 @@ declare namespace Backbone {
|
@@ -218,14 +218,14 @@ declare namespace Backbone {
|
||||||
* E - Extensions to the model constructor options. You can accept additional constructor options
|
* E - Extensions to the model constructor options. You can accept additional constructor options
|
||||||
* by listing them in the E parameter.
|
* by listing them in the E parameter.
|
||||||
*/
|
*/
|
||||||
|
@ -11,3 +11,11 @@ index a172230..b85ab4c 100644
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not use, prefer TypeScript's extend functionality.
|
* Do not use, prefer TypeScript's extend functionality.
|
||||||
|
**/
|
||||||
|
public static extend(properties: any, classProperties?: any): any;
|
||||||
|
|
||||||
|
- attributes: any;
|
||||||
|
+ attributes: T;
|
||||||
|
changed: any[];
|
||||||
|
cidPrefix: string;
|
||||||
|
cid: string;
|
||||||
|
|
|
@ -358,6 +358,12 @@ export async function getPreJoinGroupInfo(
|
||||||
export function buildGroupLink(conversation: ConversationModel): string {
|
export function buildGroupLink(conversation: ConversationModel): string {
|
||||||
const { masterKey, groupInviteLinkPassword } = conversation.attributes;
|
const { masterKey, groupInviteLinkPassword } = conversation.attributes;
|
||||||
|
|
||||||
|
strictAssert(masterKey, 'buildGroupLink requires the master key!');
|
||||||
|
strictAssert(
|
||||||
|
groupInviteLinkPassword,
|
||||||
|
'buildGroupLink requires the groupInviteLinkPassword!'
|
||||||
|
);
|
||||||
|
|
||||||
const bytes = Proto.GroupInviteLink.encode({
|
const bytes = Proto.GroupInviteLink.encode({
|
||||||
v1Contents: {
|
v1Contents: {
|
||||||
groupMasterKey: Bytes.fromBase64(masterKey),
|
groupMasterKey: Bytes.fromBase64(masterKey),
|
||||||
|
|
4
ts/model-types.d.ts
vendored
4
ts/model-types.d.ts
vendored
|
@ -290,7 +290,7 @@ export type ConversationAttributesType = {
|
||||||
discoveredUnregisteredAt?: number;
|
discoveredUnregisteredAt?: number;
|
||||||
firstUnregisteredAt?: number;
|
firstUnregisteredAt?: number;
|
||||||
draftChanged?: boolean;
|
draftChanged?: boolean;
|
||||||
draftAttachments?: Array<AttachmentDraftType>;
|
draftAttachments?: ReadonlyArray<AttachmentDraftType>;
|
||||||
draftBodyRanges?: DraftBodyRangesType;
|
draftBodyRanges?: DraftBodyRangesType;
|
||||||
draftTimestamp?: number | null;
|
draftTimestamp?: number | null;
|
||||||
hideStory?: boolean;
|
hideStory?: boolean;
|
||||||
|
@ -315,7 +315,7 @@ export type ConversationAttributesType = {
|
||||||
quotedMessageId?: string | null;
|
quotedMessageId?: string | null;
|
||||||
sealedSender?: unknown;
|
sealedSender?: unknown;
|
||||||
sentMessageCount?: number;
|
sentMessageCount?: number;
|
||||||
sharedGroupNames?: Array<string>;
|
sharedGroupNames?: ReadonlyArray<string>;
|
||||||
voiceNotePlaybackRate?: number;
|
voiceNotePlaybackRate?: number;
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
|
|
@ -1686,7 +1686,7 @@ export class ConversationModel extends window.Backbone
|
||||||
const { attributes } = message;
|
const { attributes } = message;
|
||||||
const { schemaVersion } = attributes;
|
const { schemaVersion } = attributes;
|
||||||
|
|
||||||
if (schemaVersion < Message.VERSION_NEEDED_FOR_DISPLAY) {
|
if ((schemaVersion || 0) < Message.VERSION_NEEDED_FOR_DISPLAY) {
|
||||||
// Yep, we really do want to wait for each of these
|
// Yep, we really do want to wait for each of these
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const upgradedMessage = await upgradeMessageSchema(attributes);
|
const upgradedMessage = await upgradeMessageSchema(attributes);
|
||||||
|
|
|
@ -2558,7 +2558,9 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
storyId: storyQuote?.id,
|
storyId: storyQuote?.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataMessage = await upgradeMessageSchema(withQuoteReference);
|
// There are type conflicts between ModelAttributesType and protos passed in here
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const dataMessage = await upgradeMessageSchema(withQuoteReference as any);
|
||||||
|
|
||||||
const isGroupStoryReply =
|
const isGroupStoryReply =
|
||||||
isGroup(conversation.attributes) && dataMessage.storyId;
|
isGroup(conversation.attributes) && dataMessage.storyId;
|
||||||
|
@ -2712,7 +2714,18 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!avatar) {
|
||||||
attributes.avatar = avatar;
|
attributes.avatar = avatar;
|
||||||
|
} else {
|
||||||
|
const { url, path } = avatar;
|
||||||
|
strictAssert(url, 'Avatar needs url');
|
||||||
|
strictAssert(path, 'Avatar needs path');
|
||||||
|
attributes.avatar = {
|
||||||
|
url,
|
||||||
|
path,
|
||||||
|
...avatar,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pendingGroupUpdate.avatarUpdated = true;
|
pendingGroupUpdate.avatarUpdated = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -506,9 +506,9 @@ export type DataInterface = {
|
||||||
_getAllReactions: () => Promise<Array<ReactionType>>;
|
_getAllReactions: () => Promise<Array<ReactionType>>;
|
||||||
_removeAllReactions: () => Promise<void>;
|
_removeAllReactions: () => Promise<void>;
|
||||||
getMessageBySender: (options: {
|
getMessageBySender: (options: {
|
||||||
source: string;
|
source?: string;
|
||||||
sourceUuid: UUIDStringType;
|
sourceUuid?: UUIDStringType;
|
||||||
sourceDevice: number;
|
sourceDevice?: number;
|
||||||
sent_at: number;
|
sent_at: number;
|
||||||
}) => Promise<MessageType | undefined>;
|
}) => Promise<MessageType | undefined>;
|
||||||
getMessageById: (id: string) => Promise<MessageType | undefined>;
|
getMessageById: (id: string) => Promise<MessageType | undefined>;
|
||||||
|
|
|
@ -2131,9 +2131,9 @@ async function getMessageBySender({
|
||||||
sourceDevice,
|
sourceDevice,
|
||||||
sent_at,
|
sent_at,
|
||||||
}: {
|
}: {
|
||||||
source: string;
|
source?: string;
|
||||||
sourceUuid: UUIDStringType;
|
sourceUuid?: UUIDStringType;
|
||||||
sourceDevice: number;
|
sourceDevice?: number;
|
||||||
sent_at: number;
|
sent_at: number;
|
||||||
}): Promise<MessageType | undefined> {
|
}): Promise<MessageType | undefined> {
|
||||||
const db = getInstance();
|
const db = getInstance();
|
||||||
|
@ -2147,9 +2147,9 @@ async function getMessageBySender({
|
||||||
LIMIT 2;
|
LIMIT 2;
|
||||||
`
|
`
|
||||||
).all({
|
).all({
|
||||||
source,
|
source: source || null,
|
||||||
sourceUuid,
|
sourceUuid: sourceUuid || null,
|
||||||
sourceDevice,
|
sourceDevice: sourceDevice || null,
|
||||||
sent_at,
|
sent_at,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ function sendStickerMessage(
|
||||||
// next in-memory store.
|
// next in-memory store.
|
||||||
function getAttachmentsFromConversationModel(
|
function getAttachmentsFromConversationModel(
|
||||||
conversationId: string
|
conversationId: string
|
||||||
): Array<AttachmentDraftType> {
|
): ReadonlyArray<AttachmentDraftType> {
|
||||||
const conversation = window.ConversationController.get(conversationId);
|
const conversation = window.ConversationController.get(conversationId);
|
||||||
return conversation?.get('draftAttachments') || [];
|
return conversation?.get('draftAttachments') || [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1646,6 +1646,7 @@ export const markViewed = (messageId: string): void => {
|
||||||
message.set(messageUpdaterMarkViewed(message.attributes, Date.now()));
|
message.set(messageUpdaterMarkViewed(message.attributes, Date.now()));
|
||||||
|
|
||||||
if (isIncoming(message.attributes)) {
|
if (isIncoming(message.attributes)) {
|
||||||
|
const convoAttributes = message.getConversation()?.attributes;
|
||||||
drop(
|
drop(
|
||||||
viewedReceiptsJobQueue.add({
|
viewedReceiptsJobQueue.add({
|
||||||
viewedReceipt: {
|
viewedReceipt: {
|
||||||
|
@ -1653,9 +1654,9 @@ export const markViewed = (messageId: string): void => {
|
||||||
senderE164,
|
senderE164,
|
||||||
senderUuid,
|
senderUuid,
|
||||||
timestamp,
|
timestamp,
|
||||||
isDirectConversation: isDirectConversation(
|
isDirectConversation: convoAttributes
|
||||||
message.getConversation()?.attributes
|
? isDirectConversation(convoAttributes)
|
||||||
),
|
: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import dataInterface from '../../sql/Client';
|
||||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||||
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';
|
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';
|
||||||
import { StoryViewDirectionType, StoryViewModeType } from '../../types/Stories';
|
import { StoryViewDirectionType, StoryViewModeType } from '../../types/Stories';
|
||||||
import { assertDev } from '../../util/assert';
|
import { assertDev, strictAssert } from '../../util/assert';
|
||||||
import { drop } from '../../util/drop';
|
import { drop } from '../../util/drop';
|
||||||
import { blockSendUntilConversationsAreVerified } from '../../util/blockSendUntilConversationsAreVerified';
|
import { blockSendUntilConversationsAreVerified } from '../../util/blockSendUntilConversationsAreVerified';
|
||||||
import { deleteStoryForEveryone as doDeleteStoryForEveryone } from '../../util/deleteStoryForEveryone';
|
import { deleteStoryForEveryone as doDeleteStoryForEveryone } from '../../util/deleteStoryForEveryone';
|
||||||
|
@ -371,6 +371,11 @@ function markStoryRead(
|
||||||
log.warn(`markStoryRead: no message found ${messageId}`);
|
log.warn(`markStoryRead: no message found ${messageId}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const authorId = message.attributes.sourceUuid;
|
||||||
|
strictAssert(
|
||||||
|
authorId,
|
||||||
|
'markStoryRead: The message needs a sender to mark it read!'
|
||||||
|
);
|
||||||
|
|
||||||
const isSignalOnboardingStory = message.get('sourceUuid') === SIGNAL_ACI;
|
const isSignalOnboardingStory = message.get('sourceUuid') === SIGNAL_ACI;
|
||||||
|
|
||||||
|
@ -404,7 +409,7 @@ function markStoryRead(
|
||||||
}
|
}
|
||||||
|
|
||||||
await dataInterface.addNewStoryRead({
|
await dataInterface.addNewStoryRead({
|
||||||
authorId: message.attributes.sourceUuid,
|
authorId,
|
||||||
conversationId: message.attributes.conversationId,
|
conversationId: message.attributes.conversationId,
|
||||||
storyId: messageId,
|
storyId: messageId,
|
||||||
storyReadDate,
|
storyReadDate,
|
||||||
|
|
|
@ -81,8 +81,8 @@ export function calculateExpirationTimestamp({
|
||||||
expireTimer,
|
expireTimer,
|
||||||
expirationStartTimestamp,
|
expirationStartTimestamp,
|
||||||
}: {
|
}: {
|
||||||
expireTimer: DurationInSeconds | undefined;
|
expireTimer?: DurationInSeconds | null;
|
||||||
expirationStartTimestamp: number | undefined | null;
|
expirationStartTimestamp?: number | null;
|
||||||
}): number | undefined {
|
}): number | undefined {
|
||||||
return isNumber(expirationStartTimestamp) && isNumber(expireTimer)
|
return isNumber(expirationStartTimestamp) && isNumber(expireTimer)
|
||||||
? expirationStartTimestamp + DurationInSeconds.toMillis(expireTimer)
|
? expirationStartTimestamp + DurationInSeconds.toMillis(expireTimer)
|
||||||
|
|
Loading…
Reference in a new issue