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

View file

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