create room on reive from socket

This commit is contained in:
Peter Maquiran
2024-09-13 14:03:51 +01:00
parent 4b6364fac1
commit f446517773
9 changed files with 31 additions and 84 deletions
-4
View File
@@ -6,7 +6,6 @@ import { SessionStore } from 'src/app/store/session.service';
import { Subject, timer } from 'rxjs';
import { UserTypingLocalRepository } from './data/repository/typing/user-typing-local-data-source.service';
import { UserTypingRemoteRepositoryService } from './data/repository/typing/user-typing-live-data-source.service';
import { RoomService } from 'src/app/module/chat/domain/service/room.service'
import { HttpListenToMessageLoadHistoryAdapter } from './domain/adapter';
import { ISignalRService } from 'src/app/infra/socket/adapter';
import { HttpModule } from 'src/app/infra/http/http.module';
@@ -130,12 +129,9 @@ export class ChatModule {
private signalR: SignalRService,
private localDataSource: UserTypingLocalRepository,
private UserTypingRemoteRepositoryService: UserTypingRemoteRepositoryService,
private RoomService: RoomService,
private DistributionService: DistributionService,
private RoomLastMessageService: RoomLastMessageService
) {
this.RoomService.init()
this.syncMessage()
this.listenToTyping()
}
@@ -42,6 +42,7 @@ import { BoldRemoveByRoomIdInput, BoldRemoveByRoomIdService } from 'src/app/modu
import { MemberListHttpSyncUseCase } from 'src/app/module/chat/domain/use-case/member/member-list-http-sync-use-case.ts.service'
import { RoomBoldSyncUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-bold-sync-use-case.service'
import { RoomSetLastMessageService } from 'src/app/module/chat/domain/use-case/room/room-set-last-message.service';
import { RoomGetListOnCreateUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-get-list-on-create-use-case.service';
import { IUserPhotoGetByIdInput, UserPhotoGetByIdUseCase } from 'src/app/module/chat/domain/use-case/user-photo/user-photo-get-by-id-use-case.service'
@@ -101,7 +102,8 @@ export class ChatServiceService {
private MemberListHttpSyncUseCase: MemberListHttpSyncUseCase, // dont remove
private RoomBoldSyncUseCaseService: RoomBoldSyncUseCaseService, // dont remove
private RoomSetLastMessageService: RoomSetLastMessageService, // dont remove
private UserPhotoGetByIdUseCase: UserPhotoGetByIdUseCase
private UserPhotoGetByIdUseCase: UserPhotoGetByIdUseCase,
private RoomGetListOnCreateUseCaseService: RoomGetListOnCreateUseCaseService
) {
this.MessageSocketRepositoryService.listenToDeleteMessages()
.pipe()
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { RoomService } from './room.service';
describe('RoomService', () => {
let service: RoomService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(RoomService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,29 +0,0 @@
import { Injectable } from '@angular/core';
import { RoomSocketRepositoryService } from 'src/app/module/chat/data/repository/room/room-socket-repository.service'
@Injectable({
providedIn: 'root'
})
export class RoomService {
constructor(
private RoomSocketRepositoryService: RoomSocketRepositoryService
) {}
init() {
this.OnReceiveCreateRoom()
this.OnDeleteCreateRoom()
}
OnReceiveCreateRoom() {
this.RoomSocketRepositoryService.listenToCreateRoom().subscribe((data)=> {
console.log('OnReceiveCreateRoom', data)
})
}
OnDeleteCreateRoom() {
this.RoomSocketRepositoryService.listenToDeleteRoom().subscribe((data)=> {
console.log('OnDeleteCreateRoom7', data)
})
}
}
@@ -30,7 +30,8 @@ export class RoomGetListOnCreateUseCaseService {
private OnDeleteCreateRoom() {
this.RoomSocketRepositoryService.listenToDeleteRoom().subscribe((data)=> {
console.log('OnDeleteCreateRoom7', data)
console.log('OnDeleteCreateRoom', data)
this.getRoomListUseCaseService.execute()
})
}
}
+16 -9
View File
@@ -24,6 +24,7 @@ import { BoldLocalRepository } from 'src/app/module/chat/data/repository/bold/bo
import { BoldTable } from 'src/app/infra/database/dexie/instance/chat/schema/bold';
import { RoomViewModel } from './store/model/room';
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service'
import { ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-chat',
templateUrl: './chat.page.html',
@@ -81,7 +82,8 @@ export class ChatPage implements OnInit {
private ChatServiceService: ChatServiceService,
private roomLocalDataSourceService: RoomLocalRepository,
private boldLocalRepository: BoldLocalRepository,
private MessageLocalDataSourceService: MessageLocalDataSourceService
private MessageLocalDataSourceService: MessageLocalDataSourceService,
private toastService: ToastService,
) {
window.onresize = (event) => {
@@ -343,14 +345,19 @@ export class ChatPage implements OnInit {
this.roomId = roomId;
this.RoomSelected = this.rooms.filter(e => e.id == roomId)[0]
if (window.innerWidth < 701) {
this.openMessagesModal(roomId);
}
else {
this.idSelected = roomId;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
if(this.RoomSelected?.id) {
if (window.innerWidth < 701) {
this.openMessagesModal(roomId);
}
else {
this.idSelected = roomId;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
}
} else {
console.log('conversa não existe');
// this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
}
}
@@ -67,15 +67,6 @@
</div>
<div *ngFor="let attachment of message.attachments; let i = index">
<div *ngIf="attachment.source == MessageAttachmentFileSource.Webtrix">
<ion-icon src="assets/icon/webtrix.svg" class="file-icon font-25"></ion-icon>
<!-- <ion-label>{{ attachment.fileName}}</ion-label> -->
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' && attachment.type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && attachment.type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
<ion-icon *ngIf="( msg.downloadLoader == true || msg.uploadingFile == true )" class="icon-download" src="assets/gif/theme/{{ThemeService.currentTheme}}/Blocks-loader.svg" slot="end"></ion-icon> -->
</div>
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
<img
@@ -109,7 +100,8 @@
<audio [src]="attachment.safeFile|safehtml" preload="metadata" class="flex-grow-1" controls controlsList="nodownload noplaybackrate"></audio>
</div>
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Doc" class="d-flex" (click)="openPreview(message)">
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Doc" class="d-flex" (click)="openPreview(message)">
<ion-icon *ngIf="attachment.source == MessageAttachmentFileSource.Webtrix" src="assets/icon/webtrix.svg" class="file-icon font-25"></ion-icon>
<fa-icon *ngIf="attachment.mimeType == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
<fa-icon *ngIf="attachment.mimeType == 'application/word'" icon="file-word" class="word-icon">
</fa-icon>
@@ -773,13 +773,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
viewDocument(file: any, url?: string) {
if (file.type == "application/webtrix") {
this.openViewDocumentModal(file);
}
else {
let fullUrl = "https://www.tabularium.pt" + url;
this.fileService.viewDocumentByUrl(fullUrl);
}
this.openViewDocumentModal(file);
}