load messages

This commit is contained in:
Peter Maquiran
2024-08-15 10:26:20 +01:00
parent ea4ca5c34c
commit 9697290bb7
11 changed files with 102 additions and 73 deletions
+22 -5
View File
@@ -3,6 +3,8 @@ import { SignalRService } from 'src/app/module/chat/infra/socket/signal-r.servic
import { SyncMessageRepositoryService } from './data/service/sync-repository/sync-message-repository.service';
import { UserTypingAsyncService } from 'src/app/module/chat/data/async/socket/user-typing-async.service'
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service'
import { skip } from 'rxjs/operators';
import { SessionStore } from 'src/app/store/session.service';
@NgModule({
imports: [
@@ -21,21 +23,36 @@ export class ChatModule {
private message: SyncMessageRepositoryService,
private SignalRService: SignalRService,
private UserTypingAsyncService: UserTypingAsyncService,
private ChatServiceService: ChatServiceService
private ChatServiceService: ChatServiceService
) {
this.triggerToSendOfflineMessages()
this.syncMessage()
}
triggerToSendOfflineMessages() {
const result = this.SignalRService.getConnectionState()
syncMessage() {
const connection = this.SignalRService.getConnectionState()
result.subscribe((value) => {
connection.pipe(
skip(1) // Skip the first value
).subscribe((value)=> {
if(value) {
// on reconnect
this.ChatServiceService.asyncAllRoomMessage();
}
});
connection.subscribe((value) => {
if(value) {
// on connect
console.log('send local image')
this.message.sendLocalMessages()
}
})
// on page reload sync
if(!(!SessionStore.user.Inactivity || !SessionStore.exist)) {
this.ChatServiceService.asyncAllRoomMessage();
}
}
}