mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add chat decorator
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { TableRoom } from "../../data-source/room/rooom-local-data-source.service";
|
||||
import { RoomListItemOutPutDTO } from "../../dto/room/roomListOutputDTO";
|
||||
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from "../../dto/room/roomListOutputDTO";
|
||||
|
||||
export function roomListDetermineChanges(serverRooms: RoomListItemOutPutDTO[], localRooms: TableRoom[]) {
|
||||
const serverRoomMap = new Map(serverRooms.map(room => [room.id, room]));
|
||||
|
||||
+3
-1
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
|
||||
import { RoomListOutPutDTO, RoomListOutPutDTOSchema } from '../../dto/room/roomListOutputDTO';
|
||||
import { RoomInputDTO, RoomInputDTOSchema } from '../../dto/room/roomInputDTO';
|
||||
import { RoomOutPutDTO } from '../../dto/room/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../../dto/room/addMemberToRoomInputDto';
|
||||
@@ -26,6 +26,8 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.post<RoomOutPutDTO>(`${this.baseUrl}/Room`, data);
|
||||
}
|
||||
|
||||
|
||||
@APIReturn(RoomListOutPutDTOSchema)
|
||||
async getRoomList(): Promise<DataSourceReturn<RoomListOutPutDTO>> {
|
||||
return await this.httpService.get<RoomListOutPutDTO>(`${this.baseUrl}/Room`);
|
||||
}
|
||||
|
||||
@@ -4,21 +4,21 @@ const CreatedBySchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string().email(),
|
||||
userPhoto: z.string()
|
||||
userPhoto: z.string().nullable()// api check
|
||||
});
|
||||
|
||||
const RoomListItemOutPutDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: CreatedBySchema,
|
||||
createdAt: z.string().datetime(),
|
||||
expirationDate: z.string().datetime(),
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(), // api check
|
||||
roomType: z.number()
|
||||
});
|
||||
|
||||
|
||||
// Define the schema for the entire response
|
||||
const RoomListOutPutDTOSchema = z.object({
|
||||
export const RoomListOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.array(RoomListItemOutPutDTOSchema),
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Store } from '@ngrx/store';
|
||||
import { AddMemberToRoomInputDTO } from '../dto/room/addMemberToRoomInputDto';
|
||||
import { RoomLocalDataSourceService } from '../data-source/room/rooom-local-data-source.service';
|
||||
import { RoomByIdInputDTO } from '../dto/room/roomByIdInputDTO';
|
||||
import { roomListDetermineChanges } from '../async/rooms/roomListChangeDetector';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -20,10 +21,12 @@ export class RoomRepositoryService {
|
||||
|
||||
async list() {
|
||||
const result = await this.roomRemoteDataSourceService.getRoomList()
|
||||
// const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||
const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||
|
||||
if(result.isOk()) {
|
||||
// const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges(result.value, localList)
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges(result.value.data, localList)
|
||||
|
||||
console.log({ roomsToDelete, roomsToInsert, roomsToUpdate })
|
||||
for( const roomData of result.value.data) {
|
||||
this.roomLocalDataSourceService.createOrUpdateRoom(roomData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user