2022-02-18 13:46:19 +00:00
|
|
|
import { Action } from 'redux';
|
|
|
|
|
|
|
|
import { ERoomType } from '../definitions/ERoomType';
|
|
|
|
import { ROOM } from './actionsTypes';
|
|
|
|
|
|
|
|
// TYPE RETURN RELATED
|
2022-03-02 14:49:43 +00:00
|
|
|
type ISelected = string[];
|
2022-02-18 13:46:19 +00:00
|
|
|
|
|
|
|
export interface ITransferData {
|
|
|
|
roomId: string;
|
|
|
|
userId?: string;
|
|
|
|
departmentId?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ACTION RETURN RELATED
|
|
|
|
interface IBaseReturn extends Action {
|
|
|
|
rid: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
type TSubscribeRoom = IBaseReturn;
|
|
|
|
type TUnsubscribeRoom = IBaseReturn;
|
|
|
|
|
|
|
|
type TRoom = Record<string, any>;
|
|
|
|
|
|
|
|
interface ILeaveRoom extends Action {
|
|
|
|
roomType: ERoomType;
|
|
|
|
room: TRoom;
|
|
|
|
selected?: ISelected;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IDeleteRoom extends Action {
|
|
|
|
roomType: ERoomType;
|
|
|
|
room: TRoom;
|
|
|
|
selected?: ISelected;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IForwardRoom extends Action {
|
|
|
|
transferData: ITransferData;
|
|
|
|
rid: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IUserTyping extends Action {
|
|
|
|
rid: string;
|
|
|
|
status: boolean;
|
|
|
|
}
|
|
|
|
|
2022-06-27 19:03:24 +00:00
|
|
|
export type TActionsRoom = TSubscribeRoom & TUnsubscribeRoom & ILeaveRoom & IDeleteRoom & IForwardRoom & IUserTyping;
|
2022-02-18 13:46:19 +00:00
|
|
|
|
|
|
|
export function subscribeRoom(rid: string): TSubscribeRoom {
|
|
|
|
return {
|
|
|
|
type: ROOM.SUBSCRIBE,
|
|
|
|
rid
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unsubscribeRoom(rid: string): TUnsubscribeRoom {
|
|
|
|
return {
|
|
|
|
type: ROOM.UNSUBSCRIBE,
|
|
|
|
rid
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function leaveRoom(roomType: ERoomType, room: TRoom, selected?: ISelected): ILeaveRoom {
|
|
|
|
return {
|
|
|
|
type: ROOM.LEAVE,
|
|
|
|
room,
|
|
|
|
roomType,
|
|
|
|
selected
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteRoom(roomType: ERoomType, room: TRoom, selected?: ISelected): IDeleteRoom {
|
|
|
|
return {
|
|
|
|
type: ROOM.DELETE,
|
|
|
|
room,
|
|
|
|
roomType,
|
|
|
|
selected
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function forwardRoom(rid: string, transferData: ITransferData): IForwardRoom {
|
|
|
|
return {
|
|
|
|
type: ROOM.FORWARD,
|
|
|
|
transferData,
|
|
|
|
rid
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removedRoom(): Action {
|
|
|
|
return {
|
|
|
|
type: ROOM.REMOVED
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function userTyping(rid: string, status = true): IUserTyping {
|
|
|
|
return {
|
|
|
|
type: ROOM.USER_TYPING,
|
|
|
|
rid,
|
|
|
|
status
|
|
|
|
};
|
|
|
|
}
|