verdnatura-chat/app/reducers/activeUsers.ts

28 lines
606 B
TypeScript
Raw Normal View History

2022-02-28 18:00:47 +00:00
import { ACTIVE_USERS } from '../actions/actionsTypes';
2022-03-29 18:53:10 +00:00
import { TApplicationActions, TUserStatus } from '../definitions';
2022-01-24 20:12:36 +00:00
export interface IActiveUser {
2022-03-29 18:53:10 +00:00
status: TUserStatus;
2022-02-28 18:00:47 +00:00
statusText: string;
2022-01-24 20:12:36 +00:00
}
export interface IActiveUsers {
[key: string]: IActiveUser;
}
export const initialState: IActiveUsers = {};
export default function activeUsers(state = initialState, action: TApplicationActions): IActiveUsers {
switch (action.type) {
2022-02-28 18:00:47 +00:00
case ACTIVE_USERS.SET:
2022-01-24 20:12:36 +00:00
return {
...state,
...action.activeUsers
};
2022-02-28 18:00:47 +00:00
case ACTIVE_USERS.CLEAR:
return initialState;
2022-01-24 20:12:36 +00:00
default:
return state;
}
}