ux: should not show follow requests tab when have no pending sent follow req

This commit is contained in:
Lhc_fl 2024-10-06 19:12:13 +08:00 committed by kakkokari-gtyih
parent 0959dec291
commit e580b92c37
6 changed files with 18 additions and 1 deletions

View file

@ -365,6 +365,13 @@ export class UserEntityService implements OnModuleInit {
return count > 0; return count > 0;
} }
@bindThis
public async getHasPendingSentFollowRequest(userId: MiUser['id']): Promise<boolean> {
return this.followRequestsRepository.existsBy({
followerId: userId,
});
}
@bindThis @bindThis
public getOnlineStatus(user: MiUser): 'unknown' | 'online' | 'active' | 'offline' { public getOnlineStatus(user: MiUser): 'unknown' | 'online' | 'active' | 'offline' {
if (user.hideOnlineStatus) return 'unknown'; if (user.hideOnlineStatus) return 'unknown';
@ -602,6 +609,7 @@ export class UserEntityService implements OnModuleInit {
hasUnreadChannel: false, // 後方互換性のため hasUnreadChannel: false, // 後方互換性のため
hasUnreadNotification: notificationsInfo?.hasUnread, // 後方互換性のため hasUnreadNotification: notificationsInfo?.hasUnread, // 後方互換性のため
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id), hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
hasPendingSentFollowRequest: this.getHasPendingSentFollowRequest(user.id),
unreadNotificationsCount: notificationsInfo?.unreadCount, unreadNotificationsCount: notificationsInfo?.unreadCount,
mutedWords: profile!.mutedWords, mutedWords: profile!.mutedWords,
hardMutedWords: profile!.hardMutedWords, hardMutedWords: profile!.hardMutedWords,

View file

@ -548,6 +548,10 @@ export const packedMeDetailedOnlySchema = {
type: 'boolean', type: 'boolean',
nullable: false, optional: false, nullable: false, optional: false,
}, },
hasPendingSentFollowRequest: {
type: 'boolean',
nullable: false, optional: false,
},
unreadNotificationsCount: { unreadNotificationsCount: {
type: 'number', type: 'number',
nullable: false, optional: false, nullable: false, optional: false,

View file

@ -135,6 +135,7 @@ describe('ユーザー', () => {
hasUnreadNotification: user.hasUnreadNotification, hasUnreadNotification: user.hasUnreadNotification,
unreadNotificationsCount: user.unreadNotificationsCount, unreadNotificationsCount: user.unreadNotificationsCount,
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest, hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
hasPendingSentFollowRequest: user.hasPendingSentFollowRequest,
unreadAnnouncements: user.unreadAnnouncements, unreadAnnouncements: user.unreadAnnouncements,
mutedWords: user.mutedWords, mutedWords: user.mutedWords,
hardMutedWords: user.hardMutedWords, hardMutedWords: user.hardMutedWords,
@ -372,6 +373,7 @@ describe('ユーザー', () => {
assert.strictEqual(response.hasUnreadNotification, false); assert.strictEqual(response.hasUnreadNotification, false);
assert.strictEqual(response.unreadNotificationsCount, 0); assert.strictEqual(response.unreadNotificationsCount, 0);
assert.strictEqual(response.hasPendingReceivedFollowRequest, false); assert.strictEqual(response.hasPendingReceivedFollowRequest, false);
assert.strictEqual(response.hasPendingSentFollowRequest, false);
assert.deepStrictEqual(response.unreadAnnouncements, []); assert.deepStrictEqual(response.unreadAnnouncements, []);
assert.deepStrictEqual(response.mutedWords, []); assert.deepStrictEqual(response.mutedWords, []);
assert.deepStrictEqual(response.mutedInstances, []); assert.deepStrictEqual(response.mutedInstances, []);

View file

@ -40,6 +40,7 @@ export const navbarItemDef = reactive({
followRequests: { followRequests: {
title: i18n.ts.followRequests, title: i18n.ts.followRequests,
icon: 'ti ti-user-plus', icon: 'ti ti-user-plus',
show: computed(() => $i != null && ($i.isLocked || $i.hasPendingSentFollowRequest)),
indicated: computed(() => $i != null && $i.hasPendingReceivedFollowRequest), indicated: computed(() => $i != null && $i.hasPendingReceivedFollowRequest),
to: '/my/follow-requests', to: '/my/follow-requests',
}, },

View file

@ -50,6 +50,7 @@ import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { infoImageUrl } from '@/instance.js'; import { infoImageUrl } from '@/instance.js';
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
import { $i } from '@/account';
const paginationComponent = shallowRef<InstanceType<typeof MkPagination>>(); const paginationComponent = shallowRef<InstanceType<typeof MkPagination>>();
@ -94,7 +95,7 @@ const headerTabs = computed(() => [
}, },
]); ]);
const tab = ref('list'); const tab = ref($i?.hasPendingSentFollowRequest ? 'sent' : 'list');
definePageMetadata(() => ({ definePageMetadata(() => ({
title: i18n.ts.followRequests, title: i18n.ts.followRequests,

View file

@ -3860,6 +3860,7 @@ export type components = {
hasUnreadChannel: boolean; hasUnreadChannel: boolean;
hasUnreadNotification: boolean; hasUnreadNotification: boolean;
hasPendingReceivedFollowRequest: boolean; hasPendingReceivedFollowRequest: boolean;
hasPendingSentFollowRequest: boolean;
unreadNotificationsCount: number; unreadNotificationsCount: number;
mutedWords: string[][]; mutedWords: string[][];
hardMutedWords: string[][]; hardMutedWords: string[][];