add change detector for member list on getRommById on remote data source

This commit is contained in:
Peter Maquiran
2024-06-10 22:13:10 +01:00
parent 3dc6c0e249
commit 1bfe617bfd
3 changed files with 34 additions and 8 deletions
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
import { Dexie, EntityTable, liveQuery, Observable } from 'Dexie';
import { err, ok } from 'neverthrow';
import { err, ok, Result } from 'neverthrow';
import { z } from 'zod';
const tableSchema = z.object({
@@ -89,6 +89,26 @@ export class RoomLocalDataSourceService {
}
}
async removeMemberFromRoom($roomIdUserId): Promise<Result<any ,any>> {
try {
const member = await roomDataSource.memberList.where({ $roomIdUserId: $roomIdUserId }).first();
if (member) {
const result = await ok(roomDataSource.memberList.delete($roomIdUserId));
console.log(`Member with $roomIdUserId ${$roomIdUserId} removed from room ${member.roomId}.`);
return result
} else {
console.log(`No member found with $roomIdUserId ${$roomIdUserId}`);
return
}
} catch (e) {
return err(false)
}
}
async getRoomById(id: any) {
try {
const result = await roomDataSource.room.get(id)