client uses new API for child notes depth

This commit is contained in:
Johann150 2022-07-24 23:36:07 +02:00 committed by ThatOneCalculator
parent d6a95797d8
commit b3a22f49cb
2 changed files with 13 additions and 17 deletions

View File

@ -15,12 +15,14 @@
</div>
</div>
</div>
<template v-if="depth < 5">
<MkNoteSub v-for="reply in replies" :key="reply.id" :note="reply" class="reply" :detail="true" :depth="depth + 1"/>
<template v-if="conversation">
<template v-if="depth < 5">
<MkNoteSub v-for="reply in replies" :key="reply.id" :note="reply" class="reply" :conversation="conversation" :depth="depth + 1"/>
</template>
<div v-else-if="replies.length > 0" class="more">
<MkA class="text _link" :to="notePage(note)">{{ i18n.ts.continueThread }} <i class="fas fa-angle-double-right"></i></MkA>
</div>
</template>
<div v-else class="more">
<MkA class="text _link" :to="notePage(note)">{{ i18n.ts.continueThread }} <i class="fas fa-angle-double-right"></i></MkA>
</div>
</div>
</template>
@ -36,7 +38,7 @@ import { i18n } from '@/i18n';
const props = withDefaults(defineProps<{
note: misskey.entities.Note;
detail?: boolean;
conversation?: misskey.entities.Note[];
// how many notes are in between this one and the note being viewed in detail
depth?: number;
@ -45,16 +47,7 @@ const props = withDefaults(defineProps<{
});
let showContent = $ref(false);
let replies: misskey.entities.Note[] = $ref([]);
if (props.detail) {
os.api('notes/children', {
noteId: props.note.id,
limit: 5,
}).then(res => {
replies = res;
});
}
const replies: misskey.entities.Note[] = props.conversation?.filter(item => item.replyId === props.note.id || item.renoteId === props.note.id) ?? [];
</script>
<style lang="scss" scoped>

View File

@ -99,7 +99,7 @@
</footer>
</div>
</article>
<MkNoteSub v-for="note in replies" :key="note.id" :note="note" class="reply" :detail="true"/>
<MkNoteSub v-for="note in directReplies" :key="note.id" :note="note" class="reply" :conversation="replies"/>
</div>
<div v-else class="_panel muted" @click="muted = false">
<I18n :src="i18n.ts.userSaysSomething" tag="small">
@ -182,6 +182,7 @@ const urls = appearNote.text ? extractUrlFromMfm(mfm.parse(appearNote.text)) : n
const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.user.instance);
const conversation = ref<misskey.entities.Note[]>([]);
const replies = ref<misskey.entities.Note[]>([]);
const directReplies = ref<misskey.entities.Note[]>([]);
const keymap = {
'r': () => reply(true),
@ -281,8 +282,10 @@ function blur() {
os.api('notes/children', {
noteId: appearNote.id,
limit: 100,
depth: 6,
}).then(res => {
replies.value = res;
directReplies.value = res.filter(note => note.replyId === appearNote.id || note.renoteId === appearNote.id);
});
if (appearNote.replyId) {