verdnatura-chat/app/reducers/activeUsers.ts

27 lines
588 B
TypeScript
Raw Normal View History

2022-01-24 20:12:36 +00:00
import { TApplicationActions } from '../definitions';
import { SET_ACTIVE_USERS } from '../actions/actionsTypes';
type TUserStatus = 'online' | 'offline';
export interface IActiveUser {
status: TUserStatus;
statusText?: string;
}
export interface IActiveUsers {
[key: string]: IActiveUser;
}
export const initialState: IActiveUsers = {};
export default function activeUsers(state = initialState, action: TApplicationActions): IActiveUsers {
switch (action.type) {
case SET_ACTIVE_USERS:
return {
...state,
...action.activeUsers
};
default:
return state;
}
}