await promises (#8519)

This commit is contained in:
Johann150 2022-04-19 11:46:41 +02:00 committed by GitHub
parent d338ea2591
commit 3cf226d534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 19 deletions

View file

@ -95,17 +95,12 @@ async function unFollow(follower: User, followee: User) {
return; return;
} }
Followings.delete(following.id); await Promises.all([
Followings.delete(following.id),
//#region Decrement following count Users.decrement({ id: follower.id }, 'followingCount', 1),
Users.decrement({ id: follower.id }, 'followingCount', 1); Users.decrement({ id: followee.id }, 'followersCount', 1),
//#endregion perUserFollowingChart.update(follower, followee, false),
]);
//#region Decrement followers count
Users.decrement({ id: followee.id }, 'followersCount', 1);
//#endregion
perUserFollowingChart.update(follower, followee, false);
// Publish unfollow event // Publish unfollow event
if (Users.isLocalUser(follower)) { if (Users.isLocalUser(follower)) {

View file

@ -67,8 +67,10 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
if (alreadyFollowed) return; if (alreadyFollowed) return;
//#region Increment counts //#region Increment counts
Users.increment({ id: follower.id }, 'followingCount', 1); await Promises.all([
Users.increment({ id: followee.id }, 'followersCount', 1); Users.increment({ id: follower.id }, 'followingCount', 1),
Users.increment({ id: followee.id }, 'followersCount', 1),
]);
//#endregion //#endregion
//#region Update instance stats //#region Update instance stats

View file

@ -58,12 +58,11 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
} }
export async function decrementFollowing(follower: { id: User['id']; host: User['host']; }, followee: { id: User['id']; host: User['host']; }) { export async function decrementFollowing(follower: { id: User['id']; host: User['host']; }, followee: { id: User['id']; host: User['host']; }) {
//#region Decrement following count //#region Decrement following / followers counts
Users.decrement({ id: follower.id }, 'followingCount', 1); await Promises.all([
//#endregion Users.decrement({ id: follower.id }, 'followingCount', 1),
Users.decrement({ id: followee.id }, 'followersCount', 1),
//#region Decrement followers count ]);
Users.decrement({ id: followee.id }, 'followersCount', 1);
//#endregion //#endregion
//#region Update instance stats //#region Update instance stats