Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

drafts: Remove feature for discarding drafts after 30 days.

[email protected]08c8e40afa10
diff --git a/help/view-and-edit-your-message-drafts.md b/help/view-and-edit-your-message-drafts.md
index b412d68a6c6..8a453d54f44 100644
--- a/help/view-and-edit-your-message-drafts.md
+++ b/help/view-and-edit-your-message-drafts.md
@@ -3,7 +3,7 @@
Zulip automatically saves the content of your message as a draft when you close
the compose box, ensuring that you never lose your work. When you start
composing, the most recently edited draft for the conversation you are composing
-to automatically appears in the compose box. Drafts are saved for 30 days.
+to automatically appears in the compose box.
!!! warn ""
diff --git a/web/src/drafts.ts b/web/src/drafts.ts
index 6604cc4e2b2..d7177021ae8 100644
--- a/web/src/drafts.ts
+++ b/web/src/drafts.ts
@@ -1,4 +1,3 @@
-import {subDays} from "date-fns";
import $ from "jquery";
import _ from "lodash";
import assert from "minimalistic-assert";
@@ -139,10 +138,12 @@ export const draft_model = (function () {
// intermediate versions may have generated some bugged drafts with
// this invalid topic value.
//
- // TODO/compatibility: This can be deleted once servers can no longer
- // directly upgrade from Zulip 6.0beta1 and earlier development branch where the bug was present,
- // since we expect bugged drafts will have either been run through
- // this code or else been deleted after 30 (DRAFT_LIFETIME) days.
+ // TODO/compatibility: This can be deleted once servers
+ // can no longer directly upgrade from Zulip 6.0beta1 and
+ // earlier development branch where the bug was present,
+ // since we expect bugged drafts will have either been run
+ // through this code or been deleted by the previous
+ // behavior of deleting them after 30 days.
if (draft.topic === undefined) {
draft.topic = "";
}
@@ -457,8 +458,6 @@ export function rewire_update_draft(value: typeof update_draft): void {
update_draft = value;
}
-export const DRAFT_LIFETIME = 30;
-
export function current_recipient_data(): {
stream_name: string | undefined;
topic: string | undefined;
@@ -558,16 +557,6 @@ export function get_last_restorable_draft_based_on_compose_state():
.findLast((draft) => !draft.is_sending_saving && draft.drafts_version >= 1);
}
-export function remove_old_drafts(): void {
- const old_date = subDays(new Date(), DRAFT_LIFETIME).getTime();
- const drafts = draft_model.get();
- for (const [id, draft] of Object.entries(drafts)) {
- if (draft.updatedAt !== undefined && draft.updatedAt < old_date) {
- draft_model.deleteDraft(id);
- }
- }
-}
-
export type FormattedDraft =
| {
is_stream: true;
@@ -665,8 +654,6 @@ export function format_draft(draft: LocalStorageDraftWithId): FormattedDraft | u
}
export function initialize(): void {
- remove_old_drafts();
-
// It's possible that drafts will get still have
// `is_sending_saving` set to true if the page was
// refreshed in the middle of sending a message. We
diff --git a/web/src/drafts_overlay_ui.ts b/web/src/drafts_overlay_ui.ts
index f351b45ef88..a86dc443184 100644
--- a/web/src/drafts_overlay_ui.ts
+++ b/web/src/drafts_overlay_ui.ts
@@ -164,7 +164,6 @@ export function launch(): void {
narrow_drafts_header,
narrow_drafts,
other_drafts,
- draft_lifetime: drafts.DRAFT_LIFETIME,
});
const $drafts_table = $("#drafts_table");
$drafts_table.append($(rendered));
diff --git a/web/templates/draft_table_body.hbs b/web/templates/draft_table_body.hbs
index 58910ccbbc0..4caadde56a9 100644
--- a/web/templates/draft_table_body.hbs
+++ b/web/templates/draft_table_body.hbs
@@ -9,8 +9,6 @@
<div class="header-body">
<div class="removed-drafts-message">
{{t "Drafts are not synced to other devices and browsers." }}
- <br />
- {{#tr}}Drafts older than <strong>{draft_lifetime}</strong> days are automatically removed.{{/tr}}
</div>
<div class="delete-drafts-group">
<div class="delete-selected-drafts-button-container">
diff --git a/web/tests/drafts.test.cjs b/web/tests/drafts.test.cjs
index b33f82dc64f..592396b4853 100644
--- a/web/tests/drafts.test.cjs
+++ b/web/tests/drafts.test.cjs
@@ -265,38 +265,6 @@ test("initialize", ({override_rewire}) => {
drafts_overlay_ui.initialize();
});
-test("remove_old_drafts", ({override_rewire}) => {
- const draft_3 = {
- topic: "topic",
- type: "stream",
- content: "Test stream message",
- updatedAt: Date.now(),
- is_sending_saving: false,
- drafts_version: 1,
- };
- const draft_4 = {
- private_message_recipient: "[email protected]",
- reply_to: "[email protected]",
- type: "private",
- content: "Test direct message",
- updatedAt: new Date().setDate(-30),
- is_sending_saving: false,
- drafts_version: 1,
- };
- const draft_model = drafts.draft_model;
- const ls = localstorage();
- const data = {id3: draft_3, id4: draft_4};
- ls.set("drafts", data);
- assert.deepEqual(draft_model.get(), data);
-
- const $unread_count = $("<unread-count-stub>");
- $(".top_left_drafts").set_find_results(".unread_count", $unread_count);
- override_rewire(drafts, "update_compose_draft_count", noop);
-
- drafts.remove_old_drafts();
- assert.deepEqual(draft_model.get(), {id3: draft_3});
-});
-
test("update_draft", ({override, override_rewire}) => {
compose_state.set_message_type(undefined);
let draft_id = drafts.update_draft();