mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
Merge branch 'develop' into bugfix/zoom
This commit is contained in:
@@ -45,7 +45,8 @@
|
|||||||
</ion-buttons>
|
</ion-buttons>
|
||||||
</div>
|
</div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
<ion-label (click)="asyncNotification()">{{notificationdata.length}} novas notificações</ion-label>
|
<ion-label (click)="asyncNotification()" *ngIf="notificationdata">{{notificationdata.length}} novas notificações</ion-label>
|
||||||
|
<ion-label (click)="asyncNotification()" *ngIf="!notificationdata">0 novas notificações</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
|
||||||
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
|
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
|
||||||
<div class="width-100" [ngSwitch]="segment">
|
<div class="width-100" [ngSwitch]="segment">
|
||||||
<ion-list *ngSwitchCase="'Contactos'">
|
<ion-list *ngSwitchCase="'Contactos'">
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
|
|
||||||
|
this.segment = 'Contactos'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -320,7 +322,6 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
async setIntervenient(data) {
|
async setIntervenient(data) {
|
||||||
this.taskParticipants = removeDuplicate(data)
|
this.taskParticipants = removeDuplicate(data)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setIntervenientCC(data) {
|
async setIntervenientCC(data) {
|
||||||
@@ -339,12 +340,11 @@ export class ChatPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSegmentChange() {
|
onSegmentChange() {
|
||||||
//this.load();
|
this.wsChatMethodsService.getAllRooms();
|
||||||
}
|
}
|
||||||
|
|
||||||
doRefresh(event) {
|
doRefresh(event) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
//this.load();
|
|
||||||
event.target.complete();
|
event.target.complete();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,6 @@ export class ChatPage implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getDirectMessagesDB() {
|
getDirectMessagesDB() {
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||||
this.storageservice.get("rooms").then((rooms) =>{
|
this.storageservice.get("rooms").then((rooms) =>{
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//this.loadFiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(status: string) {
|
setStatus(status: string) {
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ export class ContactsPage implements OnInit {
|
|||||||
|
|
||||||
this.room = res['room'];
|
this.room = res['room'];
|
||||||
|
|
||||||
|
|
||||||
await this.WsChatMethodsService.getAllRooms();
|
await this.WsChatMethodsService.getAllRooms();
|
||||||
this.getDirectMessage(this.room._id);
|
this.getDirectMessage(this.room._id);
|
||||||
});
|
});
|
||||||
@@ -148,7 +147,6 @@ export class ContactsPage implements OnInit {
|
|||||||
/* this.getDirectMessage(this.room._id); */
|
/* this.getDirectMessage(this.room._id); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* const modal = await this.modalController.create({
|
/* const modal = await this.modalController.create({
|
||||||
component: MessagesPage,
|
component: MessagesPage,
|
||||||
cssClass: 'group-messages',
|
cssClass: 'group-messages',
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private sqlservice: SqliteService,
|
private sqlservice: SqliteService,
|
||||||
public wsChatMethodsService: WsChatMethodsService,
|
public wsChatMethodsService: WsChatMethodsService,
|
||||||
private AttachmentsService: AttachmentsService,
|
private AttachmentsService: AttachmentsService,
|
||||||
|
|
||||||
private CameraService: CameraService,
|
private CameraService: CameraService,
|
||||||
private processesService: ProcessesService,
|
private processesService: ProcessesService,
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
@@ -150,7 +149,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
|
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
|
||||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||||
this.wsChatMethodsService.openRoom(this.roomId)
|
this.wsChatMethodsService.openRoom(this.roomId)
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ import { ThemeService } from 'src/app/services/theme.service';
|
|||||||
import { StorageService } from 'src/app/services/storage.service';
|
import { StorageService } from 'src/app/services/storage.service';
|
||||||
import { PermissionService } from 'src/app/services/permission.service';
|
import { PermissionService } from 'src/app/services/permission.service';
|
||||||
import { PermissionList } from 'src/app/models/permission/permissionList';
|
import { PermissionList } from 'src/app/models/permission/permissionList';
|
||||||
import { MessageModel, DeleteMessageModel } from '../../models/beast-orm'
|
import { MessageModel, DeleteMessageModel } from '../../models/beast-orm';
|
||||||
|
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||||
|
import { ChatService } from 'src/app/services/chat.service';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
templateUrl: './login.page.html',
|
templateUrl: './login.page.html',
|
||||||
@@ -46,6 +50,10 @@ export class LoginPage implements OnInit {
|
|||||||
public ThemeService: ThemeService,
|
public ThemeService: ThemeService,
|
||||||
private storageservice: StorageService,
|
private storageservice: StorageService,
|
||||||
public p: PermissionService,
|
public p: PermissionService,
|
||||||
|
private WsChatService: WsChatService,
|
||||||
|
private storage: Storage,
|
||||||
|
public WsChatMethodsService: WsChatMethodsService,
|
||||||
|
private ChatService: ChatService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -124,6 +132,7 @@ export class LoginPage implements OnInit {
|
|||||||
await this.authService.loginChat(attempt.ChatData.data);
|
await this.authService.loginChat(attempt.ChatData.data);
|
||||||
|
|
||||||
await this.authService.loginToChatWs();
|
await this.authService.loginToChatWs();
|
||||||
|
this.ChatService.setheader()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +143,9 @@ export class LoginPage implements OnInit {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
this.WsChatService.logout();
|
||||||
this.clearStoreService.clear();
|
this.clearStoreService.clear();
|
||||||
|
this.WsChatMethodsService.clearChat();
|
||||||
SessionStore.delete();
|
SessionStore.delete();
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
await MessageModel.deleteAll()
|
await MessageModel.deleteAll()
|
||||||
@@ -148,6 +159,7 @@ export class LoginPage implements OnInit {
|
|||||||
if(attempt.ChatData) {
|
if(attempt.ChatData) {
|
||||||
await this.authService.loginChat(attempt.ChatData.data);
|
await this.authService.loginChat(attempt.ChatData.data);
|
||||||
await this.authService.loginToChatWs();
|
await this.authService.loginToChatWs();
|
||||||
|
this.ChatService.setheader()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getToken();
|
this.getToken();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { RoomService } from './chat/room.service';
|
|||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
import { InitialsService } from './functions/initials.service';
|
import { InitialsService } from './functions/initials.service';
|
||||||
import { PermissionService } from './permission.service';
|
import { PermissionService } from './permission.service';
|
||||||
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -48,7 +48,8 @@ export class AuthService {
|
|||||||
private AttachmentsService: AttachmentsService,
|
private AttachmentsService: AttachmentsService,
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
private initialsService: InitialsService,
|
private initialsService: InitialsService,
|
||||||
public p: PermissionService, ) {
|
public p: PermissionService,
|
||||||
|
public WsChatMethodsService: WsChatMethodsService, ) {
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
|
|
||||||
@@ -201,6 +202,11 @@ export class AuthService {
|
|||||||
|
|
||||||
|
|
||||||
this.WsChatService.setStatus('online')
|
this.WsChatService.setStatus('online')
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.WsChatMethodsService.getAllRooms();
|
||||||
|
}, 200);
|
||||||
|
|
||||||
// alert('wsLogin')
|
// alert('wsLogin')
|
||||||
|
|
||||||
}).catch((message) => {
|
}).catch((message) => {
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { HttpHeaders, HttpParams } from '@angular/common/http';
|
import { HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
import { HttpService } from './http.service';
|
import { HttpService } from './http.service';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
import { PermissionService } from './permission.service';
|
import { PermissionService } from './permission.service';
|
||||||
import { SessionStore } from '../store/session.service';
|
import { SessionStore } from '../store/session.service';
|
||||||
|
import { ChangeProfileService } from 'src/app/services/change-profile.service';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -24,19 +23,21 @@ export class ChatService {
|
|||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
private authService: AuthService,
|
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
private storageService: StorageService,
|
private storageService: StorageService,
|
||||||
public p: PermissionService) {
|
public p: PermissionService,
|
||||||
|
private changeProfileService: ChangeProfileService,) {
|
||||||
|
|
||||||
this.setheader()
|
this.changeProfileService.registerCallback(() => {
|
||||||
|
this.setheader();
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocumentDetails(url: string) {
|
getDocumentDetails(url: string) {
|
||||||
let headersc = new HttpHeaders();
|
let headersc = new HttpHeaders();
|
||||||
headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId);
|
headersc = headersc.set('X-User-Id', SessionStore.user.ChatData.data.userId);
|
||||||
headersc = headersc.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
|
headersc = headersc.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
|
||||||
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
|
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
|
||||||
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
|
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
|
||||||
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
|
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
|
||||||
@@ -342,7 +343,6 @@ export class ChatService {
|
|||||||
setheader() {
|
setheader() {
|
||||||
try {
|
try {
|
||||||
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||||
this.loggedUserChat = this.authService.ValidatedUserChat;
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
|
|
||||||
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||||
@@ -360,24 +360,30 @@ export class ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshtoken() {
|
refreshtoken() {
|
||||||
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
|
|
||||||
let options = {
|
if(this.headers) {
|
||||||
headers: this.headers
|
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
|
||||||
};
|
let options = {
|
||||||
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
|
headers: this.headers
|
||||||
let data = {
|
};
|
||||||
status: res['status'],
|
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
|
||||||
data: {
|
let data = {
|
||||||
userId: res['data'].userId,
|
status: res['status'],
|
||||||
authToken: res['data'].authToken
|
data: {
|
||||||
|
userId: res['data'].userId,
|
||||||
|
authToken: res['data'].authToken
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
SessionStore.user.ChatData = data
|
||||||
SessionStore.user.ChatData = data
|
SessionStore.save()
|
||||||
SessionStore.save()
|
this.setheader()
|
||||||
|
// console.log(res)
|
||||||
|
// console.log(SessionStore.user.ChatData)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this.setheader()
|
this.setheader()
|
||||||
// console.log(res)
|
}
|
||||||
// console.log(SessionStore.user.ChatData)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export class MessageService {
|
|||||||
this.ts = ts
|
this.ts = ts
|
||||||
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""}
|
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""}
|
||||||
this.t = t
|
this.t = t
|
||||||
this._id = _id
|
this._id = _id || ""
|
||||||
this._updatedAt = _updatedAt || new Date().getTime()
|
this._updatedAt = _updatedAt || new Date().getTime()
|
||||||
this.file = file
|
this.file = file
|
||||||
this.temporaryData = temporaryData
|
this.temporaryData = temporaryData
|
||||||
@@ -310,7 +310,7 @@ export class MessageService {
|
|||||||
|
|
||||||
async addMessageDB() {
|
async addMessageDB() {
|
||||||
if(!this.addToDb) {
|
if(!this.addToDb) {
|
||||||
this.addToDb= true
|
this.addToDb = true
|
||||||
const message = this.getChatObj()
|
const message = this.getChatObj()
|
||||||
|
|
||||||
delete message.id
|
delete message.id
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export class RoomService {
|
|||||||
name = ''
|
name = ''
|
||||||
_updatedAt = {}
|
_updatedAt = {}
|
||||||
hasLoadHistory = false
|
hasLoadHistory = false
|
||||||
|
hasLoadHistoryMessageRF = []
|
||||||
restoreFromOffline = false
|
restoreFromOffline = false
|
||||||
duration = ''
|
duration = ''
|
||||||
isTyping = false
|
isTyping = false
|
||||||
@@ -179,7 +180,7 @@ export class RoomService {
|
|||||||
|
|
||||||
if(difference < 0) {
|
if(difference < 0) {
|
||||||
|
|
||||||
this.deleteRoom()
|
this.deleteRoom();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -236,18 +237,20 @@ export class RoomService {
|
|||||||
let IncomingChatMessageArgs = IncomingChatMessage.fields.args[0]
|
let IncomingChatMessageArgs = IncomingChatMessage.fields.args[0]
|
||||||
let ChatMessage : ChatMessageInterface = this.fix_updatedAt(IncomingChatMessageArgs)
|
let ChatMessage : ChatMessageInterface = this.fix_updatedAt(IncomingChatMessageArgs)
|
||||||
|
|
||||||
if(!this.messagesLocalReference.includes(ChatMessage.localReference)) {
|
const allMessageIds = this.messages.map((e)=> e._id);
|
||||||
|
|
||||||
|
if(!this.messagesLocalReference.includes(ChatMessage.localReference) && !allMessageIds.includes(ChatMessage?._id)) {
|
||||||
|
|
||||||
this.messagesLocalReference.push(ChatMessage.localReference);
|
this.messagesLocalReference.push(ChatMessage.localReference);
|
||||||
|
|
||||||
const message = await this.prepareCreate({message: ChatMessage, save: true})
|
const message = await this.prepareCreate({message: ChatMessage, save: true});
|
||||||
message.messageSend = true
|
message.messageSend = true
|
||||||
|
|
||||||
this.lastMessage = message
|
this.lastMessage = message;
|
||||||
this.calDateDuration(ChatMessage._updatedAt)
|
this.calDateDuration(ChatMessage._updatedAt);
|
||||||
|
|
||||||
if (message.t == 'r') {
|
if (message.t == 'r') {
|
||||||
this.name = message.msg
|
this.name = message.msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isSenderIsNotMe(ChatMessage)) {
|
if(this.isSenderIsNotMe(ChatMessage)) {
|
||||||
@@ -312,19 +315,17 @@ export class RoomService {
|
|||||||
this.otherUserType = args[1]
|
this.otherUserType = args[1]
|
||||||
this.readAllMessage()
|
this.readAllMessage()
|
||||||
|
|
||||||
//
|
|
||||||
// alert(JSON.stringify(args))
|
|
||||||
} else if(args[0]?.method == 'viewMessage' || args[1]?.method == 'viewMessage') {
|
} else if(args[0]?.method == 'viewMessage' || args[1]?.method == 'viewMessage') {
|
||||||
|
|
||||||
this.readAllMessage()
|
this.readAllMessage()
|
||||||
} else if(args[0]?.method == 'deleteMessage' || args[1]?.method == 'deleteMessage') {
|
} else if(args[0]?.method == 'deleteMessage' || args[1]?.method == 'deleteMessage') {
|
||||||
|
|
||||||
// alert('delete')
|
|
||||||
//
|
|
||||||
this.deleteMessage(args[1]?.method?._id)
|
this.deleteMessage(args[1]?.method?._id)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// alert('miss')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -468,7 +469,7 @@ export class RoomService {
|
|||||||
|
|
||||||
|
|
||||||
deleteAll() {
|
deleteAll() {
|
||||||
this.messages.forEach((message)=>{
|
this.messages.forEach((message) => {
|
||||||
if(message?._id) {
|
if(message?._id) {
|
||||||
this.sendDeleteRequest(message._id)
|
this.sendDeleteRequest(message._id)
|
||||||
}
|
}
|
||||||
@@ -477,7 +478,7 @@ export class RoomService {
|
|||||||
|
|
||||||
async delateMessageToSendToOthers(userId) {
|
async delateMessageToSendToOthers(userId) {
|
||||||
|
|
||||||
const deleteMessage = await DeleteMessageModel.all()
|
const deleteMessage = await DeleteMessageModel.all();
|
||||||
|
|
||||||
const toSend = deleteMessage.filter((DeleteMessage:string[])=> ! DeleteMessage.includes(userId))
|
const toSend = deleteMessage.filter((DeleteMessage:string[])=> ! DeleteMessage.includes(userId))
|
||||||
|
|
||||||
@@ -493,8 +494,8 @@ export class RoomService {
|
|||||||
|
|
||||||
this.WsChatService.deleteMessage(msgId).then(async() => {
|
this.WsChatService.deleteMessage(msgId).then(async() => {
|
||||||
message.delateRequest = true
|
message.delateRequest = true
|
||||||
await message.save()
|
await message.save();
|
||||||
this.deleteMessage(msgId)
|
this.deleteMessage(msgId);
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -516,7 +517,7 @@ export class RoomService {
|
|||||||
*/
|
*/
|
||||||
async send({file = null, attachments = null, temporaryData = {}}) {
|
async send({file = null, attachments = null, temporaryData = {}}) {
|
||||||
|
|
||||||
const localReference = uuidv4()
|
const localReference = uuidv4();
|
||||||
|
|
||||||
let offlineChatMessage = {
|
let offlineChatMessage = {
|
||||||
rid: this.id,
|
rid: this.id,
|
||||||
@@ -529,9 +530,9 @@ export class RoomService {
|
|||||||
|
|
||||||
this.message= ''
|
this.message= ''
|
||||||
|
|
||||||
|
this.messagesLocalReference.push(localReference)
|
||||||
const message: MessageService = await this.prepareCreate({message:offlineChatMessage, save: environment.chatOffline})
|
const message: MessageService = await this.prepareCreate({message:offlineChatMessage, save: environment.chatOffline})
|
||||||
|
|
||||||
this.messagesLocalReference.push(localReference)
|
|
||||||
await message.addMessageDB()
|
await message.addMessageDB()
|
||||||
message.send()
|
message.send()
|
||||||
|
|
||||||
@@ -547,7 +548,9 @@ export class RoomService {
|
|||||||
this.sortRoomList()
|
this.sortRoomList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.hasLoadHistory == false) {
|
||||||
|
this.hasLoadHistoryMessageRF.push(localReference)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -679,17 +682,17 @@ export class RoomService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
|
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
|
||||||
|
// console.log('load history', chatHistory)
|
||||||
//
|
//
|
||||||
|
|
||||||
const messagesId = this.messages.map((message)=> message._id)
|
const messagesId = this.messages.map((message)=> message._id)
|
||||||
|
|
||||||
chatHistory.result.messages.reverse().forEach(async(message: any) => {
|
await chatHistory.result.messages.reverse().forEach(async(message: any) => {
|
||||||
|
|
||||||
if (!messagesId.includes(message._id)) {
|
if (!messagesId.includes(message._id)) {
|
||||||
const messagesToSave = await this.prepareMessageCreateIfNotExist_iD({message: message});
|
const messagesToSave = await this.prepareMessageCreateIfNotExist_iD({message: message});
|
||||||
if(messagesToSave) {
|
if(messagesToSave) {
|
||||||
await messagesToSave.addMessageDB()
|
messagesToSave.addMessageDB()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,6 +706,28 @@ export class RoomService {
|
|||||||
}, 50)
|
}, 50)
|
||||||
|
|
||||||
this.hasLoadHistory = true
|
this.hasLoadHistory = true
|
||||||
|
this.messageReorder();
|
||||||
|
}
|
||||||
|
|
||||||
|
async messageReorder() {
|
||||||
|
const reorderMessage: MessageService[] = this.messages.filter((message) =>
|
||||||
|
this.hasLoadHistoryMessageRF.includes(message?.localReference)
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.messages.forEach( async (message, i) => {
|
||||||
|
|
||||||
|
if(this.hasLoadHistoryMessageRF.includes(message?.localReference)) {
|
||||||
|
this.messages.splice(i, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
this.hasLoadHistoryMessageRF = [];
|
||||||
|
|
||||||
|
reorderMessage.forEach((message) => {
|
||||||
|
this.messages.push(message)
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -714,10 +739,10 @@ export class RoomService {
|
|||||||
|
|
||||||
|
|
||||||
await this.messages.forEach( async (message, index) => {
|
await this.messages.forEach( async (message, index) => {
|
||||||
if(message._id) {
|
if(message._id) {
|
||||||
if(message.viewed.length == 0) {
|
if(message.viewed.length == 0) {
|
||||||
this.messages[index].viewed = membersIds
|
this.messages[index].viewed = membersIds;
|
||||||
this.messages[index].received = membersIds
|
this.messages[index].received = membersIds;
|
||||||
|
|
||||||
await this.messages[index].save()
|
await this.messages[index].save()
|
||||||
}
|
}
|
||||||
@@ -797,7 +822,33 @@ export class RoomService {
|
|||||||
wewMessage.setData(message)
|
wewMessage.setData(message)
|
||||||
wewMessage.loadHistory = this.hasLoadHistory
|
wewMessage.loadHistory = this.hasLoadHistory
|
||||||
|
|
||||||
this.messages.push(wewMessage)
|
|
||||||
|
let found;
|
||||||
|
|
||||||
|
if(wewMessage.localReference != null) {
|
||||||
|
found = this.messages.find((MessageService, index) => {
|
||||||
|
if ( MessageService.localReference == wewMessage.localReference ) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
found = this.messages.find((MessageService, index) => {
|
||||||
|
if ( MessageService._id == wewMessage._id) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
this.messages.push(wewMessage)
|
||||||
|
return wewMessage
|
||||||
|
}
|
||||||
|
|
||||||
return wewMessage
|
return wewMessage
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -840,7 +891,7 @@ export class RoomService {
|
|||||||
message = this.fix_updatedAt(message)
|
message = this.fix_updatedAt(message)
|
||||||
|
|
||||||
const found = this.messages.find((MessageService, index) => {
|
const found = this.messages.find((MessageService, index) => {
|
||||||
if (MessageService._id == message._id ) {
|
if (MessageService._id == message._id) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { SortService } from '../functions/sort.service';
|
|||||||
import { chatUser } from 'src/app/models/chatMethod';
|
import { chatUser } from 'src/app/models/chatMethod';
|
||||||
import { NfService } from 'src/app/services/chat/nf.service'
|
import { NfService } from 'src/app/services/chat/nf.service'
|
||||||
import { ChangeProfileService } from '../change-profile.service';
|
import { ChangeProfileService } from '../change-profile.service';
|
||||||
import { AuthService } from '../auth.service';
|
|
||||||
import { ChatStorageService } from './chat-storage.service';
|
import { ChatStorageService } from './chat-storage.service';
|
||||||
import { ChatMethodsService } from './chat-methods.service';
|
import { ChatMethodsService } from './chat-methods.service';
|
||||||
import { AESEncrypt } from '../aesencrypt.service'
|
import { AESEncrypt } from '../aesencrypt.service'
|
||||||
@@ -41,7 +40,7 @@ export class WsChatMethodsService {
|
|||||||
users: chatUser[] = []
|
users: chatUser[] = []
|
||||||
sessionStore = SessionStore
|
sessionStore = SessionStore
|
||||||
|
|
||||||
loggedUser: any;
|
|
||||||
|
|
||||||
delete = []
|
delete = []
|
||||||
|
|
||||||
@@ -56,7 +55,6 @@ export class WsChatMethodsService {
|
|||||||
private NfService: NfService,
|
private NfService: NfService,
|
||||||
private changeProfileService: ChangeProfileService,
|
private changeProfileService: ChangeProfileService,
|
||||||
private chatService: ChatService,
|
private chatService: ChatService,
|
||||||
private authService: AuthService,
|
|
||||||
private ChatStorageService: ChatStorageService,
|
private ChatStorageService: ChatStorageService,
|
||||||
private ChatMethodsService:ChatMethodsService,
|
private ChatMethodsService:ChatMethodsService,
|
||||||
private AESEncrypt: AESEncrypt,
|
private AESEncrypt: AESEncrypt,
|
||||||
@@ -64,7 +62,7 @@ export class WsChatMethodsService {
|
|||||||
private NetworkServiceService: NetworkServiceService,
|
private NetworkServiceService: NetworkServiceService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
|
||||||
|
|
||||||
this.loadChat()
|
this.loadChat()
|
||||||
|
|
||||||
@@ -93,13 +91,6 @@ export class WsChatMethodsService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// on change profile remove a rooms
|
|
||||||
this.changeProfileService.registerCallback(() => {
|
|
||||||
this.clearChat()
|
|
||||||
this.ReLoadChat()
|
|
||||||
this.storage.remove('Rooms');
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadChat() {
|
private loadChat() {
|
||||||
@@ -173,8 +164,10 @@ export class WsChatMethodsService {
|
|||||||
async getAllRooms () {
|
async getAllRooms () {
|
||||||
this.loadingWholeList = true
|
this.loadingWholeList = true
|
||||||
const rooms = await this.WsChatService.getRooms();
|
const rooms = await this.WsChatService.getRooms();
|
||||||
|
try {
|
||||||
|
await this.storage.remove('Rooms');
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
await this.storage.remove('Rooms');
|
|
||||||
|
|
||||||
await rooms.result.update.forEach( async (roomData: room, index) => {
|
await rooms.result.update.forEach( async (roomData: room, index) => {
|
||||||
const roomId = this.getRoomId(roomData);
|
const roomId = this.getRoomId(roomData);
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ export class WsChatService {
|
|||||||
//
|
//
|
||||||
if(message.result) {
|
if(message.result) {
|
||||||
if(message.result.token) {
|
if(message.result.token) {
|
||||||
|
|
||||||
this.isLogin = true
|
this.isLogin = true
|
||||||
this.loginResponse = message
|
this.loginResponse = message
|
||||||
|
|
||||||
@@ -106,6 +105,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
getRooms(roomOlder = 1480377601) {
|
getRooms(roomOlder = 1480377601) {
|
||||||
|
|
||||||
|
|
||||||
//const requestId = uuidv4()
|
//const requestId = uuidv4()
|
||||||
const requestId = uuidv4()
|
const requestId = uuidv4()
|
||||||
const message = {
|
const message = {
|
||||||
@@ -121,7 +121,6 @@ export class WsChatService {
|
|||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId) { // same request send
|
if(message.id == requestId) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
//
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
@@ -186,6 +185,7 @@ export class WsChatService {
|
|||||||
logout() {
|
logout() {
|
||||||
this.isLogin = false
|
this.isLogin = false
|
||||||
this.ws.connected = false
|
this.ws.connected = false
|
||||||
|
this.ws.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// send message to room
|
// send message to room
|
||||||
@@ -749,6 +749,7 @@ export class WsChatService {
|
|||||||
const data = JSON.parse(event.data)
|
const data = JSON.parse(event.data)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// console.log(data)
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(this.wsCallbacks)) {
|
for (const [key, value] of Object.entries(this.wsCallbacks)) {
|
||||||
if(value.type== 'Onmessage') {
|
if(value.type== 'Onmessage') {
|
||||||
@@ -777,6 +778,15 @@ export class WsChatService {
|
|||||||
|
|
||||||
onerror: (event: any) => {
|
onerror: (event: any) => {
|
||||||
|
|
||||||
|
},
|
||||||
|
disconnect:() => {
|
||||||
|
if(this.socket) {
|
||||||
|
this.socket.onopen = (event: any) => {}
|
||||||
|
this.socket.onmessage = (event: any) => {}
|
||||||
|
this.socket.onclose = (event: any) => {}
|
||||||
|
this.socket.onerror = (event: any) => {}
|
||||||
|
this.socket.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
||||||
@ViewChild('message-item') messageContainer: ElementRef;
|
@ViewChild('message-item') messageContainer: ElementRef;
|
||||||
|
|
||||||
loggedUser: any;
|
|
||||||
|
|
||||||
messages: any;
|
messages: any;
|
||||||
dm: any;
|
dm: any;
|
||||||
userPresence = '';
|
userPresence = '';
|
||||||
@@ -126,7 +124,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
private platform: Platform,
|
private platform: Platform,
|
||||||
private fileOpener: FileOpener,
|
private fileOpener: FileOpener,
|
||||||
) {
|
) {
|
||||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
|
||||||
|
|
||||||
this.checkAudioPermission()
|
this.checkAudioPermission()
|
||||||
}
|
}
|
||||||
@@ -448,15 +445,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
var str = msg.attachments[0].image_url;
|
// var str = msg.attachments[0].image_url;
|
||||||
str = str.substring(1, ((str.length) - 1));
|
// str = str.substring(1, ((str.length) - 1));
|
||||||
|
|
||||||
const encodedData = btoa(str);
|
// const encodedData = btoa(str);
|
||||||
|
|
||||||
let file = this.base64toBlob(encodedData, 'application/pdf')
|
// let file = this.base64toBlob(encodedData, 'application/pdf')
|
||||||
let fileURL = URL.createObjectURL(file)
|
// let fileURL = URL.createObjectURL(file)
|
||||||
|
|
||||||
window.open(fileURL);
|
// window.open(fileURL);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user