Skip to content

Commit

Permalink
ux: should not show follow requests tab when have no pending sent fol…
Browse files Browse the repository at this point in the history
…low req
  • Loading branch information
Lhcfl authored and kakkokari-gtyih committed Oct 28, 2024
1 parent 0959dec commit e580b92
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ export class UserEntityService implements OnModuleInit {
return count > 0;
}

@bindThis
public async getHasPendingSentFollowRequest(userId: MiUser['id']): Promise<boolean> {
return this.followRequestsRepository.existsBy({
followerId: userId,
});
}

@bindThis
public getOnlineStatus(user: MiUser): 'unknown' | 'online' | 'active' | 'offline' {
if (user.hideOnlineStatus) return 'unknown';
Expand Down Expand Up @@ -602,6 +609,7 @@ export class UserEntityService implements OnModuleInit {
hasUnreadChannel: false, // 後方互換性のため
hasUnreadNotification: notificationsInfo?.hasUnread, // 後方互換性のため
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
hasPendingSentFollowRequest: this.getHasPendingSentFollowRequest(user.id),
unreadNotificationsCount: notificationsInfo?.unreadCount,
mutedWords: profile!.mutedWords,
hardMutedWords: profile!.hardMutedWords,
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ export const packedMeDetailedOnlySchema = {
type: 'boolean',
nullable: false, optional: false,
},
hasPendingSentFollowRequest: {
type: 'boolean',
nullable: false, optional: false,
},
unreadNotificationsCount: {
type: 'number',
nullable: false, optional: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/test/e2e/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ describe('ユーザー', () => {
hasUnreadNotification: user.hasUnreadNotification,
unreadNotificationsCount: user.unreadNotificationsCount,
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
hasPendingSentFollowRequest: user.hasPendingSentFollowRequest,
unreadAnnouncements: user.unreadAnnouncements,
mutedWords: user.mutedWords,
hardMutedWords: user.hardMutedWords,
Expand Down Expand Up @@ -372,6 +373,7 @@ describe('ユーザー', () => {
assert.strictEqual(response.hasUnreadNotification, false);
assert.strictEqual(response.unreadNotificationsCount, 0);
assert.strictEqual(response.hasPendingReceivedFollowRequest, false);
assert.strictEqual(response.hasPendingSentFollowRequest, false);
assert.deepStrictEqual(response.unreadAnnouncements, []);
assert.deepStrictEqual(response.mutedWords, []);
assert.deepStrictEqual(response.mutedInstances, []);
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const navbarItemDef = reactive({
followRequests: {
title: i18n.ts.followRequests,
icon: 'ti ti-user-plus',
show: computed(() => $i != null && ($i.isLocked || $i.hasPendingSentFollowRequest)),
indicated: computed(() => $i != null && $i.hasPendingReceivedFollowRequest),
to: '/my/follow-requests',
},
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/pages/follow-requests.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { infoImageUrl } from '@/instance.js';
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
import { $i } from '@/account';

const paginationComponent = shallowRef<InstanceType<typeof MkPagination>>();

Expand Down Expand Up @@ -94,7 +95,7 @@ const headerTabs = computed(() => [
},
]);

const tab = ref('list');
const tab = ref($i?.hasPendingSentFollowRequest ? 'sent' : 'list');

definePageMetadata(() => ({
title: i18n.ts.followRequests,
Expand Down
1 change: 1 addition & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3860,6 +3860,7 @@ export type components = {
hasUnreadChannel: boolean;
hasUnreadNotification: boolean;
hasPendingReceivedFollowRequest: boolean;
hasPendingSentFollowRequest: boolean;
unreadNotificationsCount: number;
mutedWords: string[][];
hardMutedWords: string[][];
Expand Down

0 comments on commit e580b92

Please sign in to comment.