2022-01-11 13:48:01 +00:00
|
|
|
import { TApplicationActions } from '../definitions';
|
2022-02-09 20:44:53 +00:00
|
|
|
import { ACTIVE_USERS } from '../actions/actionsTypes';
|
2022-01-11 13:48:01 +00:00
|
|
|
|
2022-02-09 20:44:53 +00:00
|
|
|
type TUserStatus = 'online' | 'offline' | 'away' | 'busy';
|
2022-01-11 13:48:01 +00:00
|
|
|
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) {
|
2022-02-09 20:44:53 +00:00
|
|
|
case ACTIVE_USERS.SET:
|
2022-01-11 13:48:01 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...action.activeUsers
|
|
|
|
};
|
2022-02-09 20:44:53 +00:00
|
|
|
case ACTIVE_USERS.CLEAR:
|
|
|
|
return initialState;
|
2022-01-11 13:48:01 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|