Reduce number of SQL queries during conversation update

This commit is contained in:
Fedor Indutny 2021-08-16 09:56:27 -07:00 committed by GitHub
parent 765b3eddc4
commit 962515031d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 91 deletions

View file

@ -201,6 +201,18 @@ export type UnprocessedUpdateType = {
decrypted?: string;
};
export type LastConversationMessagesServerType = {
activity?: MessageType;
preview?: MessageType;
hasUserInitiatedMessages: boolean;
};
export type LastConversationMessagesType = {
activity?: MessageModel;
preview?: MessageModel;
hasUserInitiatedMessages: boolean;
};
export type DataInterface = {
close: () => Promise<void>;
removeDB: () => Promise<void>;
@ -302,7 +314,6 @@ export type DataInterface = {
options?: { forceSave?: boolean }
) => Promise<void>;
getMessageCount: (conversationId?: string) => Promise<number>;
hasUserInitiatedMessages: (conversationId: string) => Promise<boolean>;
getAllMessageIds: () => Promise<Array<string>>;
getMessageMetricsForConversation: (
conversationId: string
@ -476,14 +487,10 @@ export type ServerInterface = DataInterface & {
conversationId: string,
options?: { limit?: number; receivedAt?: number; sentAt?: number }
) => Promise<Array<MessageTypeUnhydrated>>;
getLastConversationActivity: (options: {
getLastConversationMessages: (options: {
conversationId: string;
ourConversationId: string;
}) => Promise<MessageType | undefined>;
getLastConversationPreview: (options: {
conversationId: string;
ourConversationId: string;
}) => Promise<MessageType | undefined>;
}) => Promise<LastConversationMessagesServerType>;
getTapToViewMessagesNeedingErase: () => Promise<Array<MessageType>>;
removeConversation: (id: Array<string> | string) => Promise<void>;
removeMessage: (id: string) => Promise<void>;
@ -576,16 +583,11 @@ export type ClientInterface = DataInterface & {
MessageCollection: typeof MessageModelCollectionType;
}
) => Promise<MessageModelCollectionType>;
getLastConversationActivity: (options: {
getLastConversationMessages: (options: {
conversationId: string;
ourConversationId: string;
Message: typeof MessageModel;
}) => Promise<MessageModel | undefined>;
getLastConversationPreview: (options: {
conversationId: string;
ourConversationId: string;
Message: typeof MessageModel;
}) => Promise<MessageModel | undefined>;
}) => Promise<LastConversationMessagesType>;
getTapToViewMessagesNeedingErase: (options: {
MessageCollection: typeof MessageModelCollectionType;
}) => Promise<MessageModelCollectionType>;