verdnatura-chat/app/reducers/activeUsers.ts

29 lines
648 B
TypeScript
Raw Normal View History

2022-02-28 18:00:47 +00:00
import { ACTIVE_USERS } from '../actions/actionsTypes';
2022-01-24 20:12:36 +00:00
import { TApplicationActions } from '../definitions';
2022-02-28 18:00:47 +00:00
import { UserStatus } from '../definitions/UserStatus';
2022-01-24 20:12:36 +00:00
export interface IActiveUser {
2022-02-28 18:00:47 +00:00
status: UserStatus;
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;
}
}