include user feed

This commit is contained in:
Hazel K 2024-10-01 18:28:04 -04:00
parent 23659ab013
commit 204e734192
2 changed files with 101 additions and 31 deletions

View file

@ -4,23 +4,19 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div :class="$style.root"> <div :class="$style.root" @click="$emit('select', note.userId)">
<div :class="$style.head"> <div :class="$style.head">
<MkAvatar :class="$style.icon" :user="note.user" link preview indictor/> <MkAvatar :class="$style.icon" :user="note.user" preview indictor/>
</div> </div>
<div :class="$style.tail"> <div :class="$style.tail">
<header :class="$style.header"> <header :class="$style.header">
<MkA v-user-preview="note.user.id" :class="$style.headerName" :to="userPage(note.user)"> <MkA v-user-preview="note.user.id" :class="$style.headerName" :to="userPage(note.user)">
<MkUserName :user="note.user"/> <MkUserName :user="note.user"/>
</MkA> </MkA>
<MkA :to="notePage(note)">
<MkTime :time="note.createdAt" :class="$style.headerTime" colored/> <MkTime :time="note.createdAt" :class="$style.headerTime" colored/>
</MkA>
</header> </header>
<div> <div>
<MkA :class="$style.text" :to="notePage(note)" :title="getNoteSummary(note)"> <Mfm :class="$style.text" :text="getNoteSummary(note)" :isBlock="false" :plain="true" :nowrap="true" :isNote="true" :author="note.user"/>
<Mfm :text="getNoteSummary(note)" :isBlock="true" :plain="true" :nowrap="true" :isNote="true" :author="note.user"/>
</MkA>
</div> </div>
</div> </div>
</div> </div>
@ -29,13 +25,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { getNoteSummary } from '@/scripts/get-note-summary.js'; import { getNoteSummary } from '@/scripts/get-note-summary.js';
import { notePage } from '@/filters/note.js';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
defineProps<{ defineProps<{
note: Misskey.entities.Note note: Misskey.entities.Note
}>(); }>();
defineEmits<{
(event: 'select', userId: string): void
}>();
</script> </script>
<style lang="scss" module> <style lang="scss" module>

View file

@ -7,9 +7,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader v-model:tab="currentTab" :actions="headerActions" :tabs="headerTabs"/></template> <template #header><MkPageHeader v-model:tab="currentTab" :actions="headerActions" :tabs="headerTabs"/></template>
<MkHorizontalSwipe v-model:tab="currentTab" :tabs="headerTabs"> <MkHorizontalSwipe v-model:tab="currentTab" :tabs="headerTabs">
<MkPullToRefresh :refresher="() => reload()">
<MkSpacer :contentMax="1200"> <MkSpacer :contentMax="1200">
<MkPagination ref="pagingComponent" :pagination="pagination"> <div :class="$style.columns">
<MkPullToRefresh :refresher="() => reloadList()">
<MkPagination ref="listPaging" :pagination="listPagination">
<template #empty> <template #empty>
<div class="_fullinfo"> <div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost" alt="No notes found" aria-hidden="true"/> <img :src="infoImageUrl" class="_ghost" alt="No notes found" aria-hidden="true"/>
@ -19,12 +20,17 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #default="{ items: notes }"> <template #default="{ items: notes }">
<MkDateSeparatedList v-slot="{ item: note }" :items="notes" :class="$style.list" :noGap="true"> <MkDateSeparatedList v-slot="{ item: note }" :items="notes" :class="$style.list" :noGap="true">
<FollowingFeedEntry :note="note"/> <FollowingFeedEntry :note="note" @select="selectUser"/>
</MkDateSeparatedList> </MkDateSeparatedList>
</template> </template>
</MkPagination> </MkPagination>
</MkSpacer>
</MkPullToRefresh> </MkPullToRefresh>
<MkPullToRefresh v-if="selectedUserId" :refresher="() => reloadUser()">
<MkNotes :noGap="true" :pagination="userPagination" :paginationComponent="userPaging"/>
</MkPullToRefresh>
</div>
</MkSpacer>
</MkHorizontalSwipe> </MkHorizontalSwipe>
</MkStickyContainer> </MkStickyContainer>
</template> </template>
@ -47,6 +53,7 @@ import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import { Tab } from '@/components/global/MkPageHeader.tabs.vue'; import { Tab } from '@/components/global/MkPageHeader.tabs.vue';
import { PageHeaderItem } from '@/types/page-header.js'; import { PageHeaderItem } from '@/types/page-header.js';
import FollowingFeedEntry from '@/components/FollowingFeedEntry.vue'; import FollowingFeedEntry from '@/components/FollowingFeedEntry.vue';
import MkNotes from '@/components/MkNotes.vue';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
initialTab?: FollowingFeedTab, initialTab?: FollowingFeedTab,
@ -60,13 +67,32 @@ const props = withDefaults(defineProps<{
const currentTab = ref(props.initialTab); const currentTab = ref(props.initialTab);
const mutualsOnly = computed(() => currentTab.value === mutualsTab); const mutualsOnly = computed(() => currentTab.value === mutualsTab);
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>(); const selectedUserId = ref('');
async function reload() { function selectUser(userId: string): void {
await pagingComponent.value?.reload(); selectedUserId.value = userId;
console.log('userId', userId);
} }
const pagination: Paging<'notes/following'> = { const listPaging = shallowRef<InstanceType<typeof MkPagination>>();
const userPaging = shallowRef<InstanceType<typeof MkPagination>>();
async function reloadList() {
await listPaging.value?.reload();
}
async function reloadUser() {
await userPaging.value?.reload();
}
async function reloadBoth() {
await Promise.all([
reloadList(),
reloadUser(),
]);
}
const listPagination: Paging<'notes/following'> = {
endpoint: 'notes/following' as const, endpoint: 'notes/following' as const,
limit: 20, limit: 20,
params: computed(() => ({ params: computed(() => ({
@ -74,11 +100,23 @@ const pagination: Paging<'notes/following'> = {
})), })),
}; };
const userPagination: Paging<'users/notes'> = {
endpoint: 'users/notes' as const,
limit: 10,
params: computed(() => ({
userId: selectedUserId.value,
withRenotes: false,
withReplies: true,
withChannelNotes: false,
withFiles: false,
})),
};
const headerActions: PageHeaderItem[] = [ const headerActions: PageHeaderItem[] = [
{ {
icon: 'ti ti-refresh', icon: 'ti ti-refresh',
text: i18n.ts.reload, text: i18n.ts.reload,
handler: () => reload(), handler: () => reloadBoth(),
}, },
]; ];
@ -106,4 +144,37 @@ definePageMetadata(() => ({
.list { .list {
background: var(--panel); background: var(--panel);
} }
.columns {
display: flex;
flex-direction: row;
width: 100%;
}
.columns > * {
flex: 1;
}
.columns > :last-child {
min-width: 60%;
}
.columns > :not(:first-child) {
margin-left: 6px;
}
.columns > :not(:last-child) {
margin-right: 6px;
}
@container (min-width: 451px) {
.columns > :not(:first-child) {
margin-left: 12px;
}
.columns > :not(:last-child) {
margin-right: 12px;
}
}
</style> </style>