mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
load messages
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user