mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
show last messae and date
This commit is contained in:
@@ -23,9 +23,7 @@ export class DistributionService {
|
||||
constructor(
|
||||
private http: HttpAdapter,
|
||||
private distributionLocalRepository: IDistributionLocalRepository
|
||||
) {
|
||||
// this.listenToLoadHistory()
|
||||
}
|
||||
) {}
|
||||
|
||||
listenToLoadHistory() {
|
||||
return this.http.listen().pipe(
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RoomLastMessageService } from './room-last-message.service';
|
||||
|
||||
describe('RoomLastMessageService', () => {
|
||||
let service: RoomLastMessageService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(RoomLastMessageService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { MessageEntity } from 'src/app/core/chat/entity/message';
|
||||
import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/message-socket-repository';
|
||||
import { InstanceId } from '../chat-service.service';
|
||||
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RoomLastMessageService {
|
||||
|
||||
constructor(
|
||||
private MessageSocketRepositoryService: IMessageSocketRepository,
|
||||
private roomLocalRepository: IRoomLocalRepository
|
||||
) {
|
||||
this.listenToIncomingMessage()
|
||||
}
|
||||
|
||||
|
||||
listenToIncomingMessage() {
|
||||
return this.MessageSocketRepositoryService.listenToMessages().pipe(
|
||||
filter((message) => !message?.requestId?.startsWith(InstanceId)),
|
||||
map(message => Object.assign(new MessageEntity(), message))
|
||||
).subscribe(async (message) => {
|
||||
this.roomLocalRepository.update(message.roomId, {
|
||||
messages: [message]
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user