mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
sync message on recoonect on ui
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user