Only re-save and re-sort conversation if draft has changed
This commit is contained in:
parent
bd13a2087f
commit
92235678b5
1 changed files with 26 additions and 12 deletions
|
@ -764,17 +764,23 @@
|
||||||
conversationUnloaded(this.model.id);
|
conversationUnloaded(this.model.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.model.hasDraft()) {
|
if (this.model.get('draftChanged')) {
|
||||||
this.model.set({
|
if (this.model.hasDraft()) {
|
||||||
draftTimestamp: Date.now(),
|
this.model.set({
|
||||||
timestamp: Date.now(),
|
draftChanged: false,
|
||||||
});
|
draftTimestamp: Date.now(),
|
||||||
|
timestamp: Date.now(),
|
||||||
this.model.updateLastMessage();
|
});
|
||||||
|
} else {
|
||||||
|
this.model.set({
|
||||||
|
draftChanged: false,
|
||||||
|
draftTimestamp: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// We don't wait here; we need to take down the view
|
// We don't wait here; we need to take down the view
|
||||||
this.saveModel();
|
this.saveModel();
|
||||||
} else {
|
|
||||||
this.model.updateLastMessage();
|
this.model.updateLastMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,6 +961,7 @@
|
||||||
const draftAttachments = this.model.get('draftAttachments') || [];
|
const draftAttachments = this.model.get('draftAttachments') || [];
|
||||||
this.model.set({
|
this.model.set({
|
||||||
draftAttachments: [...draftAttachments, onDisk],
|
draftAttachments: [...draftAttachments, onDisk],
|
||||||
|
draftChanged: true,
|
||||||
});
|
});
|
||||||
await this.saveModel();
|
await this.saveModel();
|
||||||
|
|
||||||
|
@ -969,6 +976,7 @@
|
||||||
draftAttachments,
|
draftAttachments,
|
||||||
item => item.path === attachment.path
|
item => item.path === attachment.path
|
||||||
),
|
),
|
||||||
|
draftChanged: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateAttachmentsView();
|
this.updateAttachmentsView();
|
||||||
|
@ -983,6 +991,7 @@
|
||||||
const draftAttachments = this.model.get('draftAttachments') || [];
|
const draftAttachments = this.model.get('draftAttachments') || [];
|
||||||
this.model.set({
|
this.model.set({
|
||||||
draftAttachments: [],
|
draftAttachments: [],
|
||||||
|
draftChanged: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateAttachmentsView();
|
this.updateAttachmentsView();
|
||||||
|
@ -2262,6 +2271,7 @@
|
||||||
if (existing !== messageId) {
|
if (existing !== messageId) {
|
||||||
this.model.set({
|
this.model.set({
|
||||||
quotedMessageId: messageId,
|
quotedMessageId: messageId,
|
||||||
|
draftChanged: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.saveModel();
|
await this.saveModel();
|
||||||
|
@ -2427,16 +2437,20 @@
|
||||||
if (this.model.get('draft') && (!messageText || trimmed.length === 0)) {
|
if (this.model.get('draft') && (!messageText || trimmed.length === 0)) {
|
||||||
this.model.set({
|
this.model.set({
|
||||||
draft: null,
|
draft: null,
|
||||||
|
draftChanged: true,
|
||||||
});
|
});
|
||||||
await this.saveModel();
|
await this.saveModel();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.set({
|
if (messageText !== this.model.get('draft')) {
|
||||||
draft: messageText,
|
this.model.set({
|
||||||
});
|
draft: messageText,
|
||||||
await this.saveModel();
|
draftChanged: true,
|
||||||
|
});
|
||||||
|
await this.saveModel();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
maybeGrabLinkPreview(message, caretLocation) {
|
maybeGrabLinkPreview(message, caretLocation) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue