-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Now if a leaderboard only has 1 member and they try to leave, it will throw an error saying "There are no more admins left, you cannot leave". In this case the last member should be an admin so they could just delete the leaderboard, but would be nice to not throw an error.
testaustime-backend/src/api/leaderboards.rs
Line 136 in 56fc194
| return Err(TimeError::LastAdmin); |
In that case we can just delete the database because there are no other members left anyways.
So the if condition can be changed from
if db.is_leaderboard_admin(user.identity.id, lid).await?
&& db.get_leaderboard_admin_count(lid).await? == 1
{
return Err(TimeError::LastAdmin);
}to
if getLeaderboardMemberCount(lid) == 1 {
deleteLeaderboard(lid)
}
(a real world case where I encountered this: open two browser windows, each one with a different user. Create a leaderboard, join it with both users, and make both users admins. Leave the leaderboard from one window, and then trying to leave it from the other window will throw the error)