improve chat

This commit is contained in:
Peter Maquiran
2023-01-09 14:51:00 +01:00
parent 6fad1bd688
commit efa7774c1c
2 changed files with 18 additions and 8 deletions
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import * as FIFOProcessQueue from 'fifo-process-queue';
import { async } from 'rxjs';
import { RoomService } from './room.service';
@Injectable({
@@ -21,11 +22,15 @@ export class ViewedMessageService {
room.deleteMessageToReceive(userId)
}
let n = 0
for (const message of room.messages) {
if(message.online) {
for(let id of membersIds) {
if(message.addReceived(id)) {
await message.saveChanges()
n++
setTimeout(async() => {
await message.saveChanges()
}, 100 * n)
}
}
}
@@ -44,13 +49,18 @@ export class ViewedMessageService {
const membersIds: string[] = room.membersExcludeMe.map((user)=> user._id)
let n = 0
for (const message of room.messages) {
if(message.online) {
for(let id of membersIds) {
if(message.addViewed(id)) {
message.addReceived(id)
await message.saveChanges()
n++
setTimeout(async() => {
await message.saveChanges()
}, 100 * n)
}
}
}