mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
drafts: Update drafts when topics are moved.
We've for years done this for the currently open compose box state, and it seems very natural to do this for drafts as well. Fixes #22068.
This commit is contained in:
@@ -74,7 +74,7 @@ export const draft_model = (function () {
|
||||
return id;
|
||||
};
|
||||
|
||||
exports.editDraft = function (id, draft) {
|
||||
exports.editDraft = function (id, draft, update_timestamp = true) {
|
||||
const drafts = get();
|
||||
let changed = false;
|
||||
|
||||
@@ -84,7 +84,9 @@ export const draft_model = (function () {
|
||||
|
||||
if (drafts[id]) {
|
||||
changed = !check_if_equal(drafts[id], draft);
|
||||
draft.updatedAt = getTimestamp();
|
||||
if (update_timestamp) {
|
||||
draft.updatedAt = getTimestamp();
|
||||
}
|
||||
drafts[id] = draft;
|
||||
save(drafts);
|
||||
}
|
||||
@@ -118,6 +120,17 @@ export function confirm_delete_all_drafts() {
|
||||
});
|
||||
}
|
||||
|
||||
export function rename_topic(stream_id, old_topic, new_topic) {
|
||||
const current_drafts = draft_model.get();
|
||||
for (const draft_id of Object.keys(current_drafts)) {
|
||||
const draft = current_drafts[draft_id];
|
||||
if (util.same_stream_and_topic(draft, {stream_id, topic: old_topic})) {
|
||||
draft.topic = new_topic;
|
||||
draft_model.editDraft(draft_id, draft, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function snapshot_message() {
|
||||
if (!compose_state.composing() || compose_state.message_content().length <= 2) {
|
||||
// If you aren't in the middle of composing the body of a
|
||||
|
||||
Reference in New Issue
Block a user