Skip to content

Commit

Permalink
Set draftChanged=true when changing draftAttachments, better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jan 13, 2023
1 parent 9374832 commit cd6e4bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ts/state/ducks/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ function addAttachment(
const conversation = window.ConversationController.get(conversationId);
if (conversation) {
conversation.attributes.draftAttachments = nextAttachments;
conversation.attributes.draftChanged = true;
window.Signal.Data.updateConversation(conversation.attributes);
}
};
Expand Down Expand Up @@ -716,6 +717,7 @@ function addPendingAttachment(
const conversation = window.ConversationController.get(conversationId);
if (conversation) {
conversation.attributes.draftAttachments = nextAttachments;
conversation.attributes.draftChanged = true;
window.Signal.Data.updateConversation(conversation.attributes);
}
};
Expand Down
10 changes: 4 additions & 6 deletions ts/state/ducks/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3619,15 +3619,12 @@ function onConversationClosed(
throw new Error('onConversationClosed: Conversation not found');
}

log.info(
'unloading conversation',
conversation.idForLogging(),
'due to:',
reason
);
const logId = `onConversationClosed/${conversation.idForLogging()}`;
log.info(`${logId}: unloading due to ${reason}`);

if (conversation.get('draftChanged')) {
if (conversation.hasDraft()) {
log.info(`${logId}: new draft info needs update`);
const now = Date.now();
const activeAt = conversation.get('active_at') || now;

Expand All @@ -3638,6 +3635,7 @@ function onConversationClosed(
timestamp: now,
});
} else {
log.info(`${logId}: clearing draft info`);
conversation.set({
draftChanged: false,
draftTimestamp: null,
Expand Down

0 comments on commit cd6e4bb

Please sign in to comment.