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:
Joseph Insalaco 2024-07-29 13:25:33 -04:00 committed by GitHub
parent ef4413633a
commit cf1f4f12a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 193 additions and 26 deletions

View file

@ -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;
}