Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (frontend): Refresh on note edit #24

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions .github/workflows/storybook.yml

This file was deleted.

9 changes: 6 additions & 3 deletions packages/backend/src/core/NoteUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { MiPoll, IPoll } from "@/models/Poll.js";
import { concat } from "@/misc/prelude/array.js";
import { extractHashtags } from "@/misc/extract-hashtags.js";
import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js";
import { ApiError } from "@/server/api/error.js";

type MinimumUser = {
id: MiUser['id'];
Expand Down Expand Up @@ -76,7 +77,7 @@ export class NoteUpdateService implements OnApplicationShutdown {
username: MiUser['username'],
host: MiUser['host'],
isBot: MiUser['isBot'],
}, data: Option, note: MiNote, silent = false): Promise<MiNote | null> {
}, data: Option, note: MiNote, silent = false): Promise<MiNote> {
if (data.updatedAt == null) data.updatedAt = new Date();

if (data.text) {
Expand Down Expand Up @@ -121,7 +122,7 @@ export class NoteUpdateService implements OnApplicationShutdown {
private async updateNote(user: {
id: MiUser['id'],
host: MiUser['host'],
}, note: MiNote, data: Option, tags: string[], emojis: string[]): Promise<MiNote | null> {
}, note: MiNote, data: Option, tags: string[], emojis: string[]): Promise<MiNote> {
if (data.updatedAt === null || data.updatedAt === undefined) {
data.updatedAt = new Date();
}
Expand Down Expand Up @@ -199,7 +200,9 @@ export class NoteUpdateService implements OnApplicationShutdown {
await this.notesRepository.update({ id: note.id }, values);
}

return await this.notesRepository.findOneBy({ id: note.id });
const updatedNote = await this.notesRepository.findOneBy({ id: note.id });
if (updatedNote) return updatedNote;
throw new ApiError({ message: 'Updated note has gone.', id: '6dffaa9b-f578-45ac-9755-9e64290b4528', code: 'NOTE_UPDATE_GONE' }, { noteId: note.id });
} catch (e) {
console.error(e); throw e;
}
Expand Down
9 changes: 7 additions & 2 deletions packages/backend/src/server/api/endpoints/notes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const meta = {
code: 'CANNOT_CREATE_ALREADY_EXPIRED_POLL',
id: '04da457d-b083-4055-9082-955525eda5a5',
},
updatedNoteGone: {
message: 'Updated note has gone.',
code: 'NOTE_UPDATE_GONE',
id: '6dffaa9b-f578-45ac-9755-9e64290b4528',
},
},
} as const;

Expand Down Expand Up @@ -150,9 +155,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
};

const updatedNote = await this.noteUpdateService.update(me, data, note, false);

return {
updatedNote: await this.noteEntityService.pack(updatedNote!, me),
updatedNote: await this.noteEntityService.pack(updatedNote, me),
};
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ export function post(props: Record<string, any> = {}): Promise<void> {
// Vueが渡されたコンポーネントに内部的に__propsというプロパティを生やす影響で、
// 複数のpost formを開いたときに場合によってはエラーになる
// もちろん複数のpost formを開けること自体Misskeyサイドのバグなのだが
let dispose;
let dispose: () => void;
popup(MkPostFormDialog, props, {
closed: () => {
resolve();
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ export function getNoteMenu(props: {
text: i18n.ts.editConfirm,
}).then(({ canceled }) => {
if (canceled) return;
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel, editMode: true });
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel, editMode: true })
.then(() => { location.reload(); });
// 노트 수정 사항이 바로 반영되지 않는 문제 수정을 위해 일단 넣었습니다. 수정이 되면 강제 새로고침합니다.
});
}

Expand Down
Loading