From aaf098f6974faec76dc6a053ed2db84426c0d791 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Fri, 14 Apr 2023 10:14:40 -0400 Subject: [PATCH] skip if no need to adjust --- packages/backend/src/core/AccountMoveService.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/AccountMoveService.ts b/packages/backend/src/core/AccountMoveService.ts index 3a9d70a796..9e4462df00 100644 --- a/packages/backend/src/core/AccountMoveService.ts +++ b/packages/backend/src/core/AccountMoveService.ts @@ -232,9 +232,11 @@ export class AccountMoveService { } @bindThis - private async adjustFollowingCounts(localFollowerIds: string[], oldAccount: User) { + private async adjustFollowingCounts(localFollowerIds: string[], oldAccount: User): Promise { + if (localFollowerIds.length === 0) return; + // Set the old account's following and followers counts to 0. - await this.usersRepository.update(oldAccount.id, { followersCount: 0, followingCount: 0 }); + await this.usersRepository.update({ id: oldAccount.id }, { followersCount: 0, followingCount: 0 }); // Decrease following counts of local followers by 1. await this.usersRepository.decrement({ id: In(localFollowerIds) }, 'followingCount', 1);