mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 02:53:56 -07:00
Fix various issues
This commit is contained in:
parent
3001925430
commit
c3ae4cffd6
21 changed files with 130 additions and 121 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue