upd: update notes live on feed
This commit is contained in:
parent
d869d7aa05
commit
5d40ca6568
3 changed files with 24 additions and 2 deletions
|
@ -525,7 +525,9 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
// Pack the note
|
// Pack the note
|
||||||
const noteObj = await this.noteEntityService.pack(note);
|
const noteObj = await this.noteEntityService.pack(note);
|
||||||
|
|
||||||
this.globalEventService.publishNotesStream(noteObj);
|
this.globalEventService.publishNoteStream(note.id, 'updated', {
|
||||||
|
updatedAt: note.updatedAt!,
|
||||||
|
});
|
||||||
|
|
||||||
this.roleService.addNoteToRoleTimeline(noteObj);
|
this.roleService.addNoteToRoleTimeline(noteObj);
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,9 @@ export interface NoteStreamTypes {
|
||||||
reaction: string;
|
reaction: string;
|
||||||
userId: MiUser['id'];
|
userId: MiUser['id'];
|
||||||
};
|
};
|
||||||
|
updated: {
|
||||||
|
updatedAt: Date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type NoteStreamEventTypes = {
|
type NoteStreamEventTypes = {
|
||||||
[key in keyof NoteStreamTypes]: {
|
[key in keyof NoteStreamTypes]: {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { onUnmounted, Ref } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { useStream } from '@/stream.js';
|
import { useStream } from '@/stream.js';
|
||||||
import { $i } from '@/account.js';
|
import { $i } from '@/account.js';
|
||||||
|
import * as os from '@/os.js';
|
||||||
|
|
||||||
export function useNoteCapture(props: {
|
export function useNoteCapture(props: {
|
||||||
rootEl: Ref<HTMLElement>;
|
rootEl: Ref<HTMLElement>;
|
||||||
|
@ -16,7 +17,7 @@ export function useNoteCapture(props: {
|
||||||
const note = props.note;
|
const note = props.note;
|
||||||
const connection = $i ? useStream() : null;
|
const connection = $i ? useStream() : null;
|
||||||
|
|
||||||
function onStreamNoteUpdated(noteData): void {
|
async function onStreamNoteUpdated(noteData): void {
|
||||||
const { type, id, body } = noteData;
|
const { type, id, body } = noteData;
|
||||||
|
|
||||||
if (id !== note.value.id) return;
|
if (id !== note.value.id) return;
|
||||||
|
@ -75,6 +76,22 @@ export function useNoteCapture(props: {
|
||||||
props.isDeletedRef.value = true;
|
props.isDeletedRef.value = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "updated": {
|
||||||
|
const editedNote = await os.api("notes/show", {
|
||||||
|
noteId: id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const keys = new Set<string>();
|
||||||
|
Object.keys(editedNote)
|
||||||
|
.concat(Object.keys(note.value))
|
||||||
|
.forEach((key) => keys.add(key));
|
||||||
|
keys.forEach((key) => {
|
||||||
|
note.value[key] = editedNote[key];
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue