From 75f277f461d0608baf646d363fe71019c46e0103 Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 17 Mar 2024 02:03:27 +0900 Subject: [PATCH] fix (backend): return null (instead of 0) if following/followers count is unavailable --- docs/api-change.md | 1 + packages/backend/src/models/repositories/user.ts | 4 ++-- packages/client/src/pages/user/home.vue | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/api-change.md b/docs/api-change.md index 1fac31a7a9..7bab3af1b3 100644 --- a/docs/api-change.md +++ b/docs/api-change.md @@ -4,6 +4,7 @@ Breaking changes are indicated by the :warning: icon. ## Unreleased +- :warning: `followingCount` and `followersCount` in `users/show` will be `null` (instead of 0) if these values are unavailable. - :warning: `admin/search/index-all` is removed since posts are now indexed automatically. - New optional parameters are added to `notes/search` endpoint: - `sinceDate` diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index d71cf4ac7f..7c6105d2f2 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -513,8 +513,8 @@ export const UserRepository = db.getRepository(User).extend({ location: profile!.location, birthday: profile!.birthday, fields: profile!.fields, - followersCount: followersCount || 0, - followingCount: followingCount || 0, + followersCount: followersCount ?? null, + followingCount: followingCount ?? null, notesCount: user.notesCount, pinnedNoteIds: pins.map((pin) => pin.noteId), pinnedNotes: Notes.packMany( diff --git a/packages/client/src/pages/user/home.vue b/packages/client/src/pages/user/home.vue index f4ece80aa9..13846e42d4 100644 --- a/packages/client/src/pages/user/home.vue +++ b/packages/client/src/pages/user/home.vue @@ -311,6 +311,7 @@ {{ i18n.ts.notes }} {{ i18n.ts.following }}