fix handling of note objects in NoteSimple and NoteSub
This commit is contained in:
parent
1a14424be8
commit
487cfed5f3
4 changed files with 22 additions and 20 deletions
|
|
@ -51,11 +51,13 @@ const props = defineProps<{
|
|||
const showContent = ref(prefer.s.uncollapseCW);
|
||||
const isDeleted = ref(false);
|
||||
|
||||
const mergedCW = computed(() => computeMergedCw(props.note));
|
||||
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
setupNoteViewInterruptors(note, isDeleted);
|
||||
const mergedCW = computed(() => computeMergedCw(note.value));
|
||||
|
||||
if (!note.value.isSchedule) {
|
||||
setupNoteViewInterruptors(note, null);
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: 'editScheduleNote'): void;
|
||||
|
|
@ -69,7 +71,7 @@ async function deleteScheduleNote() {
|
|||
cancelText: i18n.ts.cancel,
|
||||
});
|
||||
if (canceled) return;
|
||||
await os.apiWithDialog('notes/schedule/delete', { noteId: props.note.id })
|
||||
await os.apiWithDialog('notes/schedule/delete', { noteId: note.value.id })
|
||||
.then(() => {
|
||||
isDeleted.value = true;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ const props = withDefaults(defineProps<{
|
|||
onDeleteCallback: undefined,
|
||||
});
|
||||
|
||||
const appearNote = computed(() => getAppearNote(props.note));
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
const appearNote = computed(() => getAppearNote(note.value));
|
||||
|
||||
const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || appearNote.value.userId === $i?.id);
|
||||
|
||||
|
|
@ -161,8 +163,6 @@ const pleaseLoginContext = computed<OpenOnRemoteOptions>(() => ({
|
|||
|
||||
const currentClip = inject<Ref<Misskey.entities.Clip> | null>('currentClip', null);
|
||||
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
setupNoteViewInterruptors(note, isDeleted);
|
||||
|
||||
async function addReplyTo(replyNote: Misskey.entities.Note) {
|
||||
|
|
@ -171,7 +171,7 @@ async function addReplyTo(replyNote: Misskey.entities.Note) {
|
|||
}
|
||||
|
||||
async function removeReply(id: Misskey.entities.Note['id']) {
|
||||
const replyIdx = replies.value.findIndex(note => note.id === id);
|
||||
const replyIdx = replies.value.findIndex(reply => reply.id === id);
|
||||
if (replyIdx >= 0) {
|
||||
replies.value.splice(replyIdx, 1);
|
||||
appearNote.value.repliesCount -= 1;
|
||||
|
|
@ -267,11 +267,11 @@ function like(): void {
|
|||
}
|
||||
}
|
||||
|
||||
function undoReact(note): void {
|
||||
const oldReaction = note.myReaction;
|
||||
function undoReact(targetNote: Misskey.entities.Note): void {
|
||||
const oldReaction = targetNote.myReaction;
|
||||
if (!oldReaction) return;
|
||||
misskeyApi('notes/reactions/delete', {
|
||||
noteId: note.id,
|
||||
noteId: targetNote.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ const props = defineProps<{
|
|||
|
||||
let showContent = ref(prefer.s.uncollapseCW);
|
||||
|
||||
const mergedCW = computed(() => computeMergedCw(props.note));
|
||||
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
const mergedCW = computed(() => computeMergedCw(note.value));
|
||||
|
||||
setupNoteViewInterruptors(note, null);
|
||||
|
||||
watch(() => props.expandAllCws, (expandAllCws) => {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@ const props = withDefaults(defineProps<{
|
|||
onDeleteCallback: undefined,
|
||||
});
|
||||
|
||||
const appearNote = computed(() => getAppearNote(props.note));
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
const appearNote = computed(() => getAppearNote(note.value));
|
||||
|
||||
const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || appearNote.value.userId === $i?.id);
|
||||
const hideLine = computed(() => props.detail);
|
||||
|
|
@ -175,8 +177,6 @@ const pleaseLoginContext = computed<OpenOnRemoteOptions>(() => ({
|
|||
|
||||
const currentClip = inject<Ref<Misskey.entities.Clip> | null>('currentClip', null);
|
||||
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
setupNoteViewInterruptors(note, isDeleted);
|
||||
|
||||
async function addReplyTo(replyNote: Misskey.entities.Note) {
|
||||
|
|
@ -185,7 +185,7 @@ async function addReplyTo(replyNote: Misskey.entities.Note) {
|
|||
}
|
||||
|
||||
async function removeReply(id: Misskey.entities.Note['id']) {
|
||||
const replyIdx = replies.value.findIndex(note => note.id === id);
|
||||
const replyIdx = replies.value.findIndex(reply => reply.id === id);
|
||||
if (replyIdx >= 0) {
|
||||
replies.value.splice(replyIdx, 1);
|
||||
appearNote.value.repliesCount -= 1;
|
||||
|
|
@ -281,11 +281,11 @@ function like(): void {
|
|||
}
|
||||
}
|
||||
|
||||
function undoReact(note): void {
|
||||
const oldReaction = note.myReaction;
|
||||
function undoReact(targetNote: Misskey.entities.Note): void {
|
||||
const oldReaction = targetNote.myReaction;
|
||||
if (!oldReaction) return;
|
||||
misskeyApi('notes/reactions/delete', {
|
||||
noteId: note.id,
|
||||
noteId: targetNote.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue