sync message on recoonect on ui

This commit is contained in:
Peter Maquiran
2024-08-27 15:42:11 +01:00
parent a8395b941e
commit 7800b65cba
17 changed files with 293 additions and 33 deletions
@@ -0,0 +1,34 @@
import { HttpErrorResponse } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Result } from "neverthrow";
import { Observable } from "rxjs";
import { filter, map } from "rxjs/operators";
import { HttpAdapter } from "src/app/infra/http/adapter";
import { MessageOutPutDTO } from "src/app/module/chat/data/dto/message/messageOutputDTO";
import { z } from "zod";
const HttpListenToMessageLoadHistoryUseCaseInputSchema = z.object({
roomId: z.string()
})
export type HttpListenToMessageLoadHistoryUseCaseInput = z.infer<typeof HttpListenToMessageLoadHistoryUseCaseInputSchema>
@Injectable({
providedIn: 'root'
})
export class HttpListenToMessageLoadHistoryUseCase{
constructor(
private http: HttpAdapter
) {}
execute(input: HttpListenToMessageLoadHistoryUseCaseInput): Observable<MessageOutPutDTO> {
return this.http.listen().pipe(
filter((response)=> response.isOk()),
filter((response: any)=> {
return response.value.url.includes(`Room/${input.roomId}/Messages`)
}),
map((response: any) => response.value.data as MessageOutPutDTO)
)
}
}
@@ -1,9 +1,20 @@
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { ISignalRService } from "src/app/infra/socket/adapter";
import { z } from "zod"
const e = z.object({})
export class SocketOnConnectUseCase {
@Injectable({
providedIn: 'root'
})
export class SocketOnReconnectUseCase {
constructor() {}
execute() {}
constructor(private SignalRService: ISignalRService) {}
execute(): Observable<boolean> {
const connection = this.SignalRService.onReconnect()
return connection
}
}