feat: updateExpireTimer arg shouldCommitMessage

when testing we dont want to commit the timer update message
pull/2971/head
William Grant 2 years ago
parent 4971267c69
commit 12a29f718a

@ -810,7 +810,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
* @param providedSource the pubkey of the user who made the change * @param providedSource the pubkey of the user who made the change
* @param receivedAt the timestamp of when the change was received * @param receivedAt the timestamp of when the change was received
* @param fromSync if the change was made from a sync message * @param fromSync if the change was made from a sync message
* @param shouldCommit if the change should be committed to the DB * @param shouldCommitConvo if the conversation change should be committed to the DB
* @param shouldCommitMessage if the timer update message change should be committed to the DB
* @param existingMessage if we have an existing message model to update * @param existingMessage if we have an existing message model to update
* @returns true, if the change was made or false if it was ignored * @returns true, if the change was made or false if it was ignored
*/ */
@ -821,7 +822,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
providedSource, providedSource,
receivedAt, // is set if it comes from outside receivedAt, // is set if it comes from outside
fromSync = false, // if the update comes from a config or sync message fromSync = false, // if the update comes from a config or sync message
shouldCommit = true, shouldCommitConvo = true,
shouldCommitMessage = true,
existingMessage, existingMessage,
}: { }: {
providedDisappearingMode?: DisappearingMessageConversationModeType; providedDisappearingMode?: DisappearingMessageConversationModeType;
@ -830,7 +832,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
providedSource?: string; providedSource?: string;
receivedAt?: number; // is set if it comes from outside receivedAt?: number; // is set if it comes from outside
fromSync?: boolean; fromSync?: boolean;
shouldCommit?: boolean; shouldCommitConvo?: boolean;
shouldCommitMessage?: boolean;
existingMessage?: MessageModel; existingMessage?: MessageModel;
}): Promise<boolean> { }): Promise<boolean> {
if (this.isPublic()) { if (this.isPublic()) {
@ -937,7 +940,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
this.set('active_at', timestamp); this.set('active_at', timestamp);
} }
if (shouldCommit) { if (shouldCommitConvo) {
// tell the UI this conversation was updated // tell the UI this conversation was updated
await this.commit(); await this.commit();
} }
@ -960,7 +963,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
'updateExpireTimer() remote change' 'updateExpireTimer() remote change'
), ),
}); });
await message.commit(); if (shouldCommitMessage) {
await message.commit();
}
} }
} }
return true; return true;

@ -243,7 +243,7 @@ async function handleUserProfileUpdate(result: IncomingConfResult): Promise<Inco
providedSource: ourConvo.id, providedSource: ourConvo.id,
receivedAt: result.latestEnvelopeTimestamp, receivedAt: result.latestEnvelopeTimestamp,
fromSync: true, fromSync: true,
shouldCommit: false, shouldCommitConvo: false,
}); });
changes = success; changes = success;
if (success) { if (success) {
@ -402,7 +402,7 @@ async function handleContactsUpdate(result: IncomingConfResult): Promise<Incomin
providedSource: wrapperConvo.id, providedSource: wrapperConvo.id,
receivedAt: result.latestEnvelopeTimestamp, receivedAt: result.latestEnvelopeTimestamp,
fromSync: true, fromSync: true,
shouldCommit: false, shouldCommitConvo: false,
}); });
changes = success; changes = success;
if (success) { if (success) {
@ -640,7 +640,7 @@ async function handleLegacyGroupUpdate(latestEnvelopeTimestamp: number) {
providedSource: legacyGroupConvo.id, providedSource: legacyGroupConvo.id,
receivedAt: latestEnvelopeTimestamp, receivedAt: latestEnvelopeTimestamp,
fromSync: true, fromSync: true,
shouldCommit: false, shouldCommitConvo: false,
}); });
changes = success; changes = success;
if (success) { if (success) {

@ -462,7 +462,7 @@ export async function handleMessageJob(
fromSync: source === UserUtils.getOurPubKeyStrFromCache(), fromSync: source === UserUtils.getOurPubKeyStrFromCache(),
receivedAt: messageModel.get('received_at'), receivedAt: messageModel.get('received_at'),
existingMessage: messageModel, existingMessage: messageModel,
shouldCommit: false, shouldCommitConvo: false,
// NOTE we don't commit yet because we want to get the message id, see below // NOTE we don't commit yet because we want to get the message id, see below
}); });
window.log.debug( window.log.debug(

Loading…
Cancel
Save