Fix various issues

This commit is contained in:
seavor 2026-04-12 13:58:51 -05:00
parent 3001925430
commit c3ae4cffd6
21 changed files with 130 additions and 121 deletions

View file

@ -93,6 +93,7 @@ const initialState: ServerState = {
adminNotes: {},
replays: [],
backendDecks: null,
gamesOfUser: {},
};
export const serverReducer = (state = initialState, action: any) => {
@ -401,11 +402,12 @@ export const serverReducer = (state = initialState, action: any) => {
if (user.name !== userName) {
return user;
}
const judgeFlag = shouldBeJudge ? UserLevelFlag.IsJudge : UserLevelFlag.IsNothing;
const modFlag = shouldBeMod ? UserLevelFlag.IsModerator : UserLevelFlag.IsNothing;
let newLevel = user.userLevel;
newLevel = shouldBeMod ? (newLevel | UserLevelFlag.IsModerator) : (newLevel & ~UserLevelFlag.IsModerator);
newLevel = shouldBeJudge ? (newLevel | UserLevelFlag.IsJudge) : (newLevel & ~UserLevelFlag.IsJudge);
return {
...user,
userLevel: user.userLevel & (judgeFlag | modFlag)
userLevel: newLevel,
}
})
};
@ -475,6 +477,16 @@ export const serverReducer = (state = initialState, action: any) => {
},
};
}
case Types.GAMES_OF_USER: {
const { userName, games } = action;
return {
...state,
gamesOfUser: {
...state.gamesOfUser,
[userName]: games,
},
};
}
default:
return state;
}