rewrite chat

This commit is contained in:
Peter Maquiran
2022-01-10 23:52:33 +01:00
parent 3e4067e851
commit 7a6b2a57ea
8 changed files with 69 additions and 54 deletions
@@ -1,31 +0,0 @@
import { Injectable } from '@angular/core';
import { ChatService } from '../chat.service';
@Injectable({
providedIn: 'root'
})
export class ChatMethodsService {
constructor(private chatService: ChatService) {
}
sendMessage(roomId:string, data:any) {
let body = {
"message":
{
"rid": roomId,
"msg":"",
"file":{
"type": "application/meeting",
"subject": data.subject,
"start_date": data.start,
"end_date": data.end,
"venue": data.venue,
"id": data.id,
}
}
}
this.chatService.sendMessage(body).subscribe(res=> {});
}
}
@@ -1,13 +1,13 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ChatMethodsService } from './chat-methods.service'; import { ChatUserService } from './chat-user.service';
describe('ChatMethodsService', () => { describe('ChatUserService', () => {
let service: ChatMethodsService; let service: ChatUserService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); TestBed.configureTestingModule({});
service = TestBed.inject(ChatMethodsService); service = TestBed.inject(ChatUserService);
}); });
it('should be created', () => { it('should be created', () => {
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ChatUserService {
constructor() { }
}
+21 -1
View File
@@ -1,9 +1,29 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { RoomService } from './room.service';
import { RocketChatClientService } from 'src/app/services/socket/rocket-chat-client.service';
import { MessageService } from 'src/app/services/chat/message.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class ChatService { export class ChatService {
constructor() { } rooms: RoomService[] = []
group = []
constructor(
private RocketChatClientService: RocketChatClientService
) {
this.getAllRoomAndSubscribe()
}
getAllRoomAndSubscribe() {
this.RocketChatClientService.getRooms().then((rooms: any) => {
rooms.result.update.forEach((roomData:any) => {
const room = new RoomService(new RocketChatClientService(), new MessageService())
room.setData({id: roomData.lastMessage.rid})
});
});
}
} }
@@ -1,13 +1,13 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { MethodsService } from './methods.service'; import { MessageService } from './message.service';
describe('MethodsService', () => { describe('MessageService', () => {
let service: MethodsService; let service: MessageService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); TestBed.configureTestingModule({});
service = TestBed.inject(MethodsService); service = TestBed.inject(MessageService);
}); });
it('should be created', () => { it('should be created', () => {
+9
View File
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MessageService {
constructor() { }
}
-11
View File
@@ -1,11 +0,0 @@
import { Injectable } from '@angular/core';
import { ChatService } from '../chat.service';
@Injectable({
providedIn: 'root'
})
export class MethodsService {
constructor(private chatService: ChatService) {
}
}
+22 -3
View File
@@ -1,9 +1,28 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core'
import { RocketChatClientService } from 'src/app/services/socket/rocket-chat-client.service';
import { MessageService } from 'src/app/services/chat/message.service'
import { ChatUserService } from 'src/app/services/chat/chat-user.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class RoomService { export class RoomService {
constructor() { } massages: MessageService[] = []
chatUser: ChatUserService[] = []
id = []
constructor(
private RocketChatClientService: RocketChatClientService,
private MessageService: MessageService
) {}
setData({id}){
this.id= id
}
create() {}
sendMessage() {}
deleteMessage() {}
ReactToMessage() {}
} }