2022-01-11 13:48:01 +00:00
|
|
|
import { TApplicationActions } from '../definitions';
|
|
|
|
import { SET_ACTIVE_USERS } from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
type TUserStatus = 'online' | 'offline';
|
|
|
|
export interface IActiveUser {
|
|
|
|
status: TUserStatus;
|
2022-01-18 15:04:40 +00:00
|
|
|
statusText: string;
|
2022-01-11 13:48:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|