mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 02:53:56 -07:00
Updating Session Persistence with all valid persistence calls (#5085)
* Updating Session Persistence with all valid persistence calls * Spacing fixes --------- Co-authored-by: Zach H <zahalpern+github@gmail.com>
This commit is contained in:
parent
ef4413633a
commit
cf1f4f12a9
8 changed files with 193 additions and 26 deletions
|
|
@ -31,6 +31,10 @@ const initialState: ServerState = {
|
|||
order: SortDirection.ASC
|
||||
},
|
||||
connectOptions: {},
|
||||
messages: {},
|
||||
userInfo: {},
|
||||
notifications: [],
|
||||
serverShutdown: null,
|
||||
};
|
||||
|
||||
export const serverReducer = (state = initialState, action: any) => {
|
||||
|
|
@ -162,7 +166,9 @@ export const serverReducer = (state = initialState, action: any) => {
|
|||
status: { ...status }
|
||||
}
|
||||
}
|
||||
case Types.UPDATE_USER: {
|
||||
case Types.UPDATE_USER:
|
||||
case Types.ACCOUNT_EDIT_CHANGED:
|
||||
case Types.ACCOUNT_IMAGE_CHANGED: {
|
||||
const { user } = action;
|
||||
|
||||
return {
|
||||
|
|
@ -227,6 +233,51 @@ export const serverReducer = (state = initialState, action: any) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
case Types.USER_MESSAGE: {
|
||||
const { senderName, receiverName } = action.messageData;
|
||||
const userName = state.user.name === senderName ? receiverName : senderName;
|
||||
|
||||
return {
|
||||
...state,
|
||||
messages: {
|
||||
...state.messages,
|
||||
[userName]: [
|
||||
...state.messages[userName],
|
||||
action.messageData,
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
case Types.GET_USER_INFO: {
|
||||
const { userInfo } = action;
|
||||
|
||||
return {
|
||||
...state,
|
||||
userInfo: {
|
||||
...state.userInfo,
|
||||
[userInfo.name]: userInfo,
|
||||
}
|
||||
};
|
||||
}
|
||||
case Types.NOTIFY_USER: {
|
||||
const { notification } = action;
|
||||
|
||||
return {
|
||||
...state,
|
||||
notifications: [
|
||||
...state.notifications,
|
||||
notification
|
||||
]
|
||||
};
|
||||
}
|
||||
case Types.SERVER_SHUTDOWN: {
|
||||
const { data } = action;
|
||||
|
||||
return {
|
||||
...state,
|
||||
serverShutdown: data,
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue