mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add interface
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import { createAction, createFeatureSelector, createReducer, createSelector, on, props } from "@ngrx/store";
|
||||
import { TableRoom } from "./rooom-local-data-source.service";
|
||||
import { RoomOutPutDTO } from "../../dto/room/roomOutputDTO";
|
||||
|
||||
export interface Room {
|
||||
roomName: string;
|
||||
text: string;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export interface ChatRoom {
|
||||
[roomId: string]: Room[];
|
||||
[roomId: string]: TableRoom[];
|
||||
}
|
||||
|
||||
export interface RoomRemoteDataSourceState {
|
||||
@@ -27,7 +24,7 @@ export const addMessage = createAction(
|
||||
|
||||
export const addRoom = createAction(
|
||||
'[Chat] Add Room',
|
||||
props<Room>()
|
||||
props<RoomOutPutDTO>()
|
||||
);
|
||||
|
||||
const _chatReducer = createReducer(
|
||||
@@ -39,11 +36,11 @@ const _chatReducer = createReducer(
|
||||
[roomId]: [...(state.chatRooms[roomId] || []), message]
|
||||
}
|
||||
})),
|
||||
on(addRoom, (state, roomData: Room) => ({
|
||||
on(addRoom, (state, roomData: RoomOutPutDTO) => ({
|
||||
...state,
|
||||
chatRooms: {
|
||||
...state.chatRooms,
|
||||
[roomData.roomName]: roomData
|
||||
[roomData.data.roomName]: roomData.data
|
||||
}
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -29,11 +29,7 @@ export class RoomRepositoryService {
|
||||
const result = await this.roomRemoteDataSourceService.createRoom(data)
|
||||
|
||||
if(result.isOk()) {
|
||||
this.roomMemoryDataSourceService.dispatch(addRoom({
|
||||
text: '',
|
||||
timestamp: 0,
|
||||
roomName: data.roomName
|
||||
}))
|
||||
this.roomMemoryDataSourceService.dispatch( addRoom(result.value) )
|
||||
|
||||
this.roomLocalDataSourceService.createRoom(result.value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user