verdnatura-chat/app/reducers/room.ts

63 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

import { TActionsRoom } from '../actions/room';
import { ROOM } from '../actions/actionsTypes';
export type IRoomRecord = string[];
export interface IRoom {
rid: string;
isDeleting: boolean;
rooms: IRoomRecord;
}
export const initialState: IRoom = {
rid: '',
isDeleting: false,
rooms: []
};
export default function (state = initialState, action: TActionsRoom): IRoom {
switch (action.type) {
case ROOM.SUBSCRIBE:
return {
...state,
rooms: [action.rid, ...state.rooms]
};
case ROOM.UNSUBSCRIBE:
return {
...state,
rooms: state.rooms.filter(rid => rid !== action.rid)
};
case ROOM.LEAVE:
return {
...state,
rid: action.room.rid,
isDeleting: true
};
case ROOM.DELETE:
return {
...state,
rid: action.room.rid,
isDeleting: true
};
[NEW] Livechat (#2004) * [WIP][NEW] Livechat info/actions * [IMPROVEMENT] RoomActionsView * [NEW] Visitor Navigation * [NEW] Get Department REST * [FIX] Borders * [IMPROVEMENT] Refactor RoomInfo View * [FIX] Error while navigate from mention -> roomInfo * [NEW] Livechat Fields * [NEW] Close Livechat * [WIP] Forward livechat * [NEW] Return inquiry * [WIP] Comment when close livechat * [WIP] Improve roomInfo * [IMPROVEMENT] Forward room * [FIX] Department picker * [FIX] Picker without results * [FIX] Superfluous argument * [FIX] Check permissions on RoomActionsView * [FIX] Livechat permissions * [WIP] Show edit to livechat * [I18N] Add pt-br translations * [WIP] Livechat Info * [IMPROVEMENT] Livechat info * [WIP] Livechat Edit * [WIP] Livechat edit * [WIP] Livechat Edit * [WIP] Livechat edit scroll * [FIX] Edit customFields * [FIX] Clean livechat customField * [FIX] Visitor Navigation * [NEW] Next input logic LivechatEdit * [FIX] Add livechat data to subscription * [FIX] Revert change * [NEW] Livechat user Status * [WIP] Livechat tags * [NEW] Edit livechat tags * [FIX] Prevent some crashes * [FIX] Forward * [FIX] Return Livechat error * [FIX] Prevent livechat info crash * [IMPROVEMENT] Use input style on forward chat * OnboardingSeparator -> OrSeparator * [FIX] Go to next input * [NEW] Added some icons * [NEW] Livechat close * [NEW] Forward Room Action * [FIX] Livechat edit style * [FIX] Change status logic * [CHORE] Remove unnecessary logic * [CHORE] Remove unnecessary code * [CHORE] Remove unecessary case * [FIX] Superfluous argument * [IMPROVEMENT] Submit livechat edit * [CHORE] Remove textInput type * [FIX] Livechat edit * [FIX] Livechat Edit * [FIX] Use same effect * [IMPROVEMENT] Tags input * [FIX] Add empty tag * Fix minor issues * Fix typo * insert livechat room data to our room object * review * add method calls server version Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-05-08 17:36:10 +00:00
case ROOM.CLOSE:
return {
...state,
rid: action.rid,
isDeleting: true
};
case ROOM.FORWARD:
return {
...state,
rid: action.rid,
isDeleting: true
};
case ROOM.REMOVED:
return {
...state,
isDeleting: false
};
default:
return state;
}
}