reload user info when switching tabs
This commit is contained in:
parent
508e76b672
commit
444b02ecdd
@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="$style.root">
|
<div :class="$style.root">
|
||||||
<MkPageHeader :class="$style.header" v-model:tab="currentTab" :tabs="headerTabs" :actions="headerActions"/>
|
<MkPageHeader :class="$style.header" v-model:tab="currentTab" :tabs="headerTabs" :actions="headerActions" @update:tab="onChangeTab"/>
|
||||||
|
|
||||||
<div :class="$style.notes">
|
<div :class="$style.notes">
|
||||||
<MkHorizontalSwipe v-model:tab="currentTab" :tabs="headerTabs">
|
<MkHorizontalSwipe v-model:tab="currentTab" :tabs="headerTabs">
|
||||||
@ -109,11 +109,13 @@ async function showUserNotes(userId: string): Promise<void> {
|
|||||||
selectedUserId.value = userId;
|
selectedUserId.value = userId;
|
||||||
selectedUser.value = null;
|
selectedUser.value = null;
|
||||||
|
|
||||||
// Wait for 1 second to match the animation effects in MkHorizontalSwipe, MkPullToRefresh, and MkPagination.
|
|
||||||
// Otherwise, the page appears to load "backwards".
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
|
// Wait for 1 second to match the animation effects in MkHorizontalSwipe, MkPullToRefresh, and MkPagination.
|
||||||
|
// Otherwise, the page appears to load "backwards".
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
|
||||||
|
// We need a User entity, but the pagination returns only UserLite.
|
||||||
|
// An additional request is needed to "upgrade" the object.
|
||||||
await misskeyApi('users/show', { userId })
|
await misskeyApi('users/show', { userId })
|
||||||
.then(user => selectedUser.value = user)
|
.then(user => selectedUser.value = user)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -146,11 +148,14 @@ async function onListReady(): Promise<void> {
|
|||||||
if (!selectedUserId.value && latestNotesPaging.value?.items.size) {
|
if (!selectedUserId.value && latestNotesPaging.value?.items.size) {
|
||||||
// This just gets the first user ID
|
// This just gets the first user ID
|
||||||
const selectedNote: Misskey.entities.Note = latestNotesPaging.value.items.values().next().value;
|
const selectedNote: Misskey.entities.Note = latestNotesPaging.value.items.values().next().value;
|
||||||
|
|
||||||
await showUserNotes(selectedNote.userId);
|
await showUserNotes(selectedNote.userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onChangeTab(): Promise<void> {
|
||||||
|
await showUserNotes('');
|
||||||
|
}
|
||||||
|
|
||||||
const latestNotesPaging = shallowRef<InstanceType<typeof MkPagination>>();
|
const latestNotesPaging = shallowRef<InstanceType<typeof MkPagination>>();
|
||||||
|
|
||||||
const latestNotesPagination: Paging<'notes/following'> = {
|
const latestNotesPagination: Paging<'notes/following'> = {
|
||||||
|
Loading…
Reference in New Issue
Block a user