move note view interruptor code to plugin.ts
This commit is contained in:
parent
ca2351378a
commit
1a14424be8
9 changed files with 51 additions and 171 deletions
|
|
@ -285,7 +285,7 @@ import { boostMenuItems, computeRenoteTooltip } from '@/utility/boost-quote.js';
|
|||
import { instance, isEnabledUrlPreview, policies } from '@/instance.js';
|
||||
import { getAppearNote } from '@/utility/get-appear-note.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
import { getPluginHandlers } from '@/plugin.js';
|
||||
import { setupNoteViewInterruptors } from '@/plugin.js';
|
||||
import { DI } from '@/di.js';
|
||||
import SkMutedNote from '@/components/SkMutedNote.vue';
|
||||
import SkNoteTranslation from '@/components/SkNoteTranslation.vue';
|
||||
|
|
@ -304,26 +304,6 @@ const inChannel = inject('inChannel', null);
|
|||
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
// plugin
|
||||
const noteViewInterruptors = getPluginHandlers('note_view_interruptor');
|
||||
if (noteViewInterruptors.length > 0) {
|
||||
onMounted(async () => {
|
||||
let result: Misskey.entities.Note | null = deepClone(note.value);
|
||||
for (const interruptor of noteViewInterruptors) {
|
||||
try {
|
||||
result = await interruptor.handler(result!) as Misskey.entities.Note | null;
|
||||
if (result === null) {
|
||||
isDeleted.value = true;
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
note.value = result as Misskey.entities.Note;
|
||||
});
|
||||
}
|
||||
|
||||
const isRenote = Misskey.note.isPureRenote(note.value);
|
||||
|
||||
const rootEl = useTemplateRef('rootEl');
|
||||
|
|
@ -361,6 +341,8 @@ const renoteTooltip = computeRenoteTooltip(renoted);
|
|||
|
||||
const { muted } = checkMutes(appearNote.value);
|
||||
|
||||
setupNoteViewInterruptors(note, isDeleted);
|
||||
|
||||
watch(() => props.expandAllCws, (expandAllCws) => {
|
||||
if (expandAllCws !== showContent.value) showContent.value = expandAllCws;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue