fix: don't load text of empty draft

this fixes a small ux quirk where blanking a reply and cancelling it
results in an empty reply next time you try to reply to that note, accidentally
un-tagging everyone
This commit is contained in:
ShittyKopper 2023-11-27 22:12:20 +03:00
parent 5bc036180f
commit 2f5c51c1ca

View file

@ -923,12 +923,19 @@ onMounted(() => {
if (!props.instant && !props.mention && !props.specified && !props.mock) { if (!props.instant && !props.mention && !props.specified && !props.mock) {
const draft = JSON.parse(miLocalStorage.getItem('drafts') ?? '{}')[draftKey.value]; const draft = JSON.parse(miLocalStorage.getItem('drafts') ?? '{}')[draftKey.value];
if (draft) { if (draft) {
text.value = draft.data.text; if (typeof draft.data.text === 'string' && draft.data.text.trim()) {
text.value = draft.data.text;
}
if (typeof draft.data.cw === 'string' && draft.data.cw.trim()) {
cw.value = draft.data.cw;
}
useCw.value = draft.data.useCw; useCw.value = draft.data.useCw;
cw.value = draft.data.cw;
visibility.value = draft.data.visibility; visibility.value = draft.data.visibility;
localOnly.value = draft.data.localOnly; localOnly.value = draft.data.localOnly;
files.value = (draft.data.files || []).filter(draftFile => draftFile); files.value = (draft.data.files || []).filter(draftFile => draftFile);
if (draft.data.poll) { if (draft.data.poll) {
poll.value = draft.data.poll; poll.value = draft.data.poll;
} }