chore: migrate activeUsers reducer and action to TS
This commit is contained in:
parent
b75e192e20
commit
3b97c34959
|
@ -1,8 +0,0 @@
|
|||
import { SET_ACTIVE_USERS } from './actionsTypes';
|
||||
|
||||
export function setActiveUsers(activeUsers) {
|
||||
return {
|
||||
type: SET_ACTIVE_USERS,
|
||||
activeUsers
|
||||
};
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { Action } from 'redux';
|
||||
|
||||
import { ActiveUsers } from '../reducers/activeUsers';
|
||||
import { SET_ACTIVE_USERS } from './actionsTypes';
|
||||
|
||||
export interface SetActiveUsers extends Action {
|
||||
type: typeof SET_ACTIVE_USERS;
|
||||
activeUsers: ActiveUsers;
|
||||
}
|
||||
|
||||
export const setActiveUsers = (activeUsers: ActiveUsers): SetActiveUsers => ({
|
||||
type: SET_ACTIVE_USERS,
|
||||
activeUsers
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
import { SET_ACTIVE_USERS } from '../actions/actionsTypes';
|
||||
|
||||
const initialState = {};
|
||||
|
||||
export default function activeUsers(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case SET_ACTIVE_USERS:
|
||||
return {
|
||||
...state,
|
||||
...action.activeUsers
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import { SetActiveUsers } from '../actions/activeUsers';
|
||||
import { SET_ACTIVE_USERS } from '../actions/actionsTypes';
|
||||
|
||||
type UserStatus = 'online' | 'offline';
|
||||
|
||||
interface ActiveUser {
|
||||
readonly status: UserStatus;
|
||||
readonly statusText?: string;
|
||||
}
|
||||
|
||||
export interface ActiveUsers {
|
||||
[key: string]: ActiveUser;
|
||||
}
|
||||
|
||||
const initialState: ActiveUsers = {};
|
||||
|
||||
export default function activeUsers(state = initialState, action: SetActiveUsers): ActiveUsers {
|
||||
switch (action.type) {
|
||||
case SET_ACTIVE_USERS:
|
||||
return {
|
||||
...state,
|
||||
...action.activeUsers
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue