client uses new API for child notes depth

This commit is contained in:
Johann150 2022-07-24 23:36:07 +02:00
parent c35372a20d
commit 46fff77acc
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
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

@ -100,7 +100,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">
@ -183,6 +183,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),
@ -282,8 +283,10 @@ function blur() {
os.api('notes/children', {
noteId: appearNote.id,
limit: 30,
depth: 6,
}).then(res => {
replies.value = res;
directReplies.value = res.filter(note => note.replyId === appearNote.id || note.renoteId === appearNote.id);
});
if (appearNote.replyId) {