fix(frontend/MkPostForm): 何らかの理由でファイルのアップロード・選択に失敗したゴミデータが残り投稿できなくなる問題を修正 (MisskeyIO#534)
This commit is contained in:
parent
e332c1f9a2
commit
86e63d1e4f
|
@ -421,7 +421,8 @@ function chooseFileFrom(ev) {
|
||||||
if (props.mock) return;
|
if (props.mock) return;
|
||||||
|
|
||||||
selectFiles(ev.currentTarget ?? ev.target, i18n.ts.attachFile).then(files_ => {
|
selectFiles(ev.currentTarget ?? ev.target, i18n.ts.attachFile).then(files_ => {
|
||||||
for (const file of files_) {
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
for (const file of files_.filter(f => f?.id)) {
|
||||||
files.value.push(file);
|
files.value.push(file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -450,7 +451,7 @@ function upload(file: File, name?: string): void {
|
||||||
if (props.mock) return;
|
if (props.mock) return;
|
||||||
|
|
||||||
uploadFile(file, defaultStore.state.uploadFolder, name).then(res => {
|
uploadFile(file, defaultStore.state.uploadFolder, name).then(res => {
|
||||||
files.value.push(res);
|
if (res.id) files.value.push(res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +658,7 @@ function onDrop(ev: DragEvent): void {
|
||||||
const driveFile = ev.dataTransfer?.getData(_DATA_TRANSFER_DRIVE_FILE_);
|
const driveFile = ev.dataTransfer?.getData(_DATA_TRANSFER_DRIVE_FILE_);
|
||||||
if (driveFile != null && driveFile !== '') {
|
if (driveFile != null && driveFile !== '') {
|
||||||
const file = JSON.parse(driveFile);
|
const file = JSON.parse(driveFile);
|
||||||
files.value.push(file);
|
if (file?.id) files.value.push(file);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
@ -676,7 +677,8 @@ function saveDraft() {
|
||||||
cw: cw.value,
|
cw: cw.value,
|
||||||
visibility: visibility.value,
|
visibility: visibility.value,
|
||||||
localOnly: localOnly.value,
|
localOnly: localOnly.value,
|
||||||
files: files.value,
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
files: files.value.filter(f => f?.id && f.type && f.name),
|
||||||
poll: poll.value,
|
poll: poll.value,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -747,7 +749,8 @@ async function post(ev?: MouseEvent) {
|
||||||
|
|
||||||
let postData = {
|
let postData = {
|
||||||
text: text.value === '' ? null : text.value,
|
text: text.value === '' ? null : text.value,
|
||||||
fileIds: files.value.length > 0 ? files.value.map(f => f.id) : undefined,
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
fileIds: files.value.length > 0 ? files.value.filter(f => f?.id).map(f => f.id) : undefined,
|
||||||
replyId: props.reply ? props.reply.id : undefined,
|
replyId: props.reply ? props.reply.id : undefined,
|
||||||
renoteId: props.renote ? props.renote.id : quoteId.value ? quoteId.value : undefined,
|
renoteId: props.renote ? props.renote.id : quoteId.value ? quoteId.value : undefined,
|
||||||
channelId: props.channel ? props.channel.id : undefined,
|
channelId: props.channel ? props.channel.id : undefined,
|
||||||
|
@ -946,7 +949,8 @@ onMounted(() => {
|
||||||
cw.value = draft.data.cw;
|
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);
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
files.value = draft.data.files?.filter(f => f?.id && f.type && f.name) || [];
|
||||||
if (draft.data.poll) {
|
if (draft.data.poll) {
|
||||||
poll.value = draft.data.poll;
|
poll.value = draft.data.poll;
|
||||||
}
|
}
|
||||||
|
@ -957,7 +961,8 @@ onMounted(() => {
|
||||||
if (props.initialNote) {
|
if (props.initialNote) {
|
||||||
const init = props.initialNote;
|
const init = props.initialNote;
|
||||||
text.value = init.text ? init.text : '';
|
text.value = init.text ? init.text : '';
|
||||||
files.value = init.files ?? [];
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
files.value = init.files?.filter(f => f?.id && f.type && f.name) ?? [];
|
||||||
cw.value = init.cw ?? null;
|
cw.value = init.cw ?? null;
|
||||||
useCw.value = init.cw != null;
|
useCw.value = init.cw != null;
|
||||||
if (init.poll) {
|
if (init.poll) {
|
||||||
|
|
Loading…
Reference in New Issue