drafts: Append a space to draft when restoring it.

If a user starts typing before they see that a draft was restored,
this makes that experience a little smoother by adding some
separation between the old draft and the new text.
This commit is contained in:
evykassirer
2024-03-19 15:34:10 -07:00
committed by Tim Abbott
parent d48de6da08
commit fd4246def5
2 changed files with 8 additions and 3 deletions

View File

@@ -312,7 +312,12 @@ export function start(raw_opts: ComposeActionsStartOpts): void {
const possible_last_draft = drafts.get_last_draft_based_on_compose_state();
if (possible_last_draft !== undefined) {
opts.draft_id = possible_last_draft.id;
opts.content = possible_last_draft.content;
// Add a space at the end so that if the user starts typing
// as soon as the composebox opens, they have a bit of separation
// from the restored draft. This won't result in a long trail of
// spaces if a draft is restored several times, because we trim
// whitespace whenever we save drafts.
opts.content = possible_last_draft.content + " ";
}
}