This commit is contained in:
Peter Maquiran
2022-03-03 22:57:33 +01:00
parent 3a81e6df4d
commit f5880fec2a
15 changed files with 877 additions and 801 deletions
+123 -121
View File
@@ -81,7 +81,9 @@ export interface Message {
editedBy: EditedBy; editedBy: EditedBy;
urls: any[]; urls: any[];
temporaryData: object temporaryData: object
localReference?: string localReference?: string,
viewed: string[],
received: string[],
} }
@@ -174,159 +176,159 @@ export interface chatHistory {
interface Ts { interface Ts {
$date: any; $date: any;
} }
interface U { interface U {
_id: string; _id: string;
username: string; username: string;
name: string; name: string;
} }
interface UpdatedAt { interface UpdatedAt {
$date: any; $date: any;
} }
interface Attachment { interface Attachment {
ts: Date; ts: Date;
title_link_download: boolean; title_link_download: boolean;
} }
export interface File { export interface File {
type: string; type: string;
guid: string; guid: string;
image_url: string; image_url: string;
subject: string; subject: string;
start_date?: Date; start_date?: Date;
end_date?: Date; end_date?: Date;
venue: string; venue: string;
id: string; id: string;
} }
interface EditedAt { interface EditedAt {
$date: number; $date: number;
} }
interface EditedBy { interface EditedBy {
_id: string; _id: string;
username: string; username: string;
} }
interface Ts2 { interface Ts2 {
$date: number; $date: number;
} }
interface U2 { interface U2 {
_id: string; _id: string;
username: string; username: string;
name: string; name: string;
} }
interface UpdatedAt2 { interface UpdatedAt2 {
$date: number; $date: number;
} }
interface FirstUnread { interface FirstUnread {
_id: string; _id: string;
rid: string; rid: string;
msg: string; msg: string;
ts: Ts2; ts: Ts2;
u: U2; u: U2;
_updatedAt: string; _updatedAt: string;
mentions: any[]; mentions: any[];
channels: any[]; channels: any[];
} }
export interface Message { export interface Message {
customFields:any; customFields:any;
_id: string; _id: string;
rid: string; rid: string;
msg: string; msg: string;
ts: Ts; ts: Ts;
u: U; u: U;
t: string; t: string;
_updatedAt: ''; _updatedAt: '';
mentions: any[]; mentions: any[];
channels: any[]; channels: any[];
attachments: Attachment[]; attachments: Attachment[];
file: File; file: File;
editedAt: EditedAt; editedAt: EditedAt;
editedBy: EditedBy; editedBy: EditedBy;
urls: any[]; urls: any[];
} }
export interface Lm { export interface Lm {
$date: any; $date: any;
} }
export interface LastMessage { export interface LastMessage {
_id: string; _id: string;
rid: string; rid: string;
msg: string; msg: string;
ts: Ts; ts: Ts;
u: U; u: U;
_updatedAt: UpdatedAt2; _updatedAt: UpdatedAt2;
mentions: any[]; mentions: any[];
channels: any[]; channels: any[];
file: File; file: File;
attachments: Attachment[]; attachments: Attachment[];
} }
export interface CustomFields { export interface CustomFields {
} }
export interface Update { export interface Update {
_id: string; _id: string;
t: string; t: string;
usernames: string[]; usernames: string[];
usersCount: number; usersCount: number;
uids: string[]; uids: string[];
default: boolean; default: boolean;
ro: boolean; ro: boolean;
sysMes: boolean; sysMes: boolean;
_updatedAt: UpdatedAt; _updatedAt: UpdatedAt;
lm: Lm; lm: Lm;
lastMessage: LastMessage; lastMessage: LastMessage;
name: string; name: string;
fname: string; fname: string;
u: U2; u: U2;
customFields: CustomFields; customFields: CustomFields;
} }
export interface DeletedAt { export interface DeletedAt {
$date: any; $date: any;
} }
export interface Remove { export interface Remove {
_id: string; _id: string;
_deletedAt: DeletedAt; _deletedAt: DeletedAt;
} }
export interface Result { export interface Result {
update: Update[]; update: Update[];
remove: Remove[]; remove: Remove[];
} }
export interface Rooms { export interface Rooms {
msg: string; msg: string;
id: string; id: string;
result: Result; result: Result;
} }
export interface ChatMessage { export interface ChatMessage {
msg: string; msg: string;
id: string; id: string;
result: Message result: Message
} }
@@ -334,44 +336,44 @@ export interface ChatMessage {
export interface chatHistory { export interface chatHistory {
msg: string; msg: string;
id: string; id: string;
result: { result: {
messages: Message[]; messages: Message[];
firstUnread: FirstUnread; firstUnread: FirstUnread;
unreadNotLoaded: number; unreadNotLoaded: number;
}; };
} }
export interface chatUser { export interface chatUser {
_id: string; _id: string;
createdAt: Date; createdAt: Date;
emails: { emails: {
address: string; address: string;
verified: boolean; verified: boolean;
} }
type: string; type: string;
status: string; status: 'online' | 'offline' | 'away' | 'busy' ;
active: boolean; active: boolean;
_updatedAt: Date; _updatedAt: Date;
roles: string[]; roles: string[];
name: string; name: string;
lastLogin: Date; lastLogin: Date;
statusConnection: string; statusConnection: string;
utcOffset: number; utcOffset: number;
username: string; username: string;
__rooms: string[]; __rooms: string[];
requirePasswordChange?: boolean; requirePasswordChange?: boolean;
settings: { settings: {
preferences: { preferences: {
language: string; language: string;
}; };
}; };
nickname: string; nickname: string;
statusText: string; statusText: string;
banners: any; banners: any;
statusDefault: string; statusDefault: string;
language: string; language: string;
avatarOrigin: string; avatarOrigin: string;
avatarETag?: any; avatarETag?: any;
} }
@@ -162,7 +162,7 @@
</ion-toolbar> </ion-toolbar>
</ion-footer> --> </ion-footer> -->
<ion-footer> <ion-footer >
<div class="typing" *ngIf="wsChatMethodsService.getDmRoom(roomId).otherUserType == true"> <div class="typing" *ngIf="wsChatMethodsService.getDmRoom(roomId).otherUserType == true">
@@ -3,7 +3,6 @@
</ion-header> </ion-header>
<ion-content id="main-content" class="container-wrapper"> <ion-content id="main-content" class="container-wrapper">
<div class="main-content d-flex flex-column height-100" *ngIf="loadedEvent" > <div class="main-content d-flex flex-column height-100" *ngIf="loadedEvent" >
<div class="pl-20 pr-20 text-center d-flex justify-center align-center" style="width:100%; height: 30px; background-color: var(--Event-approve-header-color); border-top-right-radius: 25px;border-top-left-radius: 25px;"> <div class="pl-20 pr-20 text-center d-flex justify-center align-center" style="width:100%; height: 30px; background-color: var(--Event-approve-header-color); border-top-right-radius: 25px;border-top-left-radius: 25px;">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="right-icons font-28" src="assets/images/icons-received-event.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="right-icons font-28" src="assets/images/icons-received-event.svg"></ion-icon>
@@ -15,103 +14,105 @@
</div> </div>
</div> </div>
<div class="content d-flex flex-column width-100" *ngIf="loadedEvent.workflowInstanceDataFields"> <div class="main-content d-flex height-100 width-100">
<div class="header-content width-100 d-flex justify-space-between"> <div class="content d-flex flex-column width-100" *ngIf="loadedEvent.workflowInstanceDataFields">
<div (click)="goBack()" class="header-icon-left cursor-pointer"> <div class="header-content width-100 d-flex justify-space-between">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-arrow-arrow-left.svg"></ion-icon> <div (click)="goBack()" class="header-icon-left cursor-pointer">
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-arrow-arrow-left.svg"></ion-icon>
</div> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
<div class="header-title flex-grow-1 cursor-pointer" *ngIf="loadedEvent.workflowInstanceDataFields.Subject">
<label>{{loadedEvent.workflowInstanceDataFields.Subject}}</label>
</div>
<div (click)="editar(loadedEvent.serialNumber)" class="header-icon-right display-none-true">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-edit.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="edit" slot="end" src="assets/images/theme/gov/icons-edit.svg" ></ion-icon>
</div>
<div class="menu-ptions">
<button class="btn-no-color" (click)="openOptions(loadedEvent)">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-menu.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg"></ion-icon>
</button>
</div>
</div>
<div class="upper-content d-flex flex-column">
<div class="content-location">
<p>
<span class="location">{{loadedEvent.workflowInstanceDataFields.Location}}</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial MDGPR' " style="background-color: #ffb703;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal MDGPR' " style="background-color: #f05d5e;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial PR' " style="background-color: #99e47b;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal PR' " style="background-color: #958bfc;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
</p>
</div>
<div class="content-details">
<ion-label>
<p>{{customDate}}</p>
<p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) == toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">das {{loadedEvent.workflowInstanceDataFields.StartDate | date: 'HH:mm'}} às {{loadedEvent.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
<p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) != toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">{{loadedEvent.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ loadedEvent.workflowInstanceDataFields.StartDate | date: 'dd/M/yy'}} </p>
<p *ngIf="loadedEvent.workflowInstanceDataFields.OccurrenceType == '-1'">(Não se repete)</p>
<p *ngIf="loadedEvent.workflowInstanceDataFields.OccurrenceType != '-1'">Repete</p>
</ion-label>
</div>
</div>
<div class="line"></div>
<div class="overflow-y-auto">
<div class="middle-content">
<div *ngIf="loadedEvent.workflowInstanceDataFields.ParticipantsList">
<h5>Intervenientes</h5>
<div *ngFor="let att of loadedEvent.workflowInstanceDataFields.ParticipantsList">
<ion-label>{{att.Name}}</ion-label>
</div>
<div class="line"></div>
</div> </div>
<div *ngIf="loadedEvent.workflowInstanceDataFields.Body"> <div class="header-title flex-grow-1 cursor-pointer" *ngIf="loadedEvent.workflowInstanceDataFields.Subject">
<h5>Detalhes</h5> <label>{{loadedEvent.workflowInstanceDataFields.Subject}}</label>
<ion-item lines="none" class="ion-no-margin ion-no-padding"> </div>
<p [innerHTML]="loadedEvent.workflowInstanceDataFields.Body"></p> <div (click)="editar(loadedEvent.serialNumber)" class="header-icon-right display-none-true">
</ion-item> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-edit.svg"></ion-icon>
<div class="line"></div> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="edit" slot="end" src="assets/images/theme/gov/icons-edit.svg" ></ion-icon>
</div>
<div class="menu-ptions">
<button class="btn-no-color" (click)="openOptions(loadedEvent)">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-menu.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg"></ion-icon>
</button>
</div> </div>
</div> </div>
<div class="upper-content d-flex flex-column">
<div *ngIf="loadedEvent.Documents" class="bottom-content width-100"> <div class="content-location">
<ion-list> <p>
<h5>Documentos Anexados</h5> <span class="location">{{loadedEvent.workflowInstanceDataFields.Location}}</span>
<ion-item class="ion-no-margin ion-no-padding cursor-pointer"
*ngFor="let attachment of loadedEvent.Documents" <span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial MDGPR' " style="background-color: #ffb703;">
(click)="viewDocument(attachment.DocId, attachment)"> {{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal MDGPR' " style="background-color: #f05d5e;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial PR' " style="background-color: #99e47b;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal PR' " style="background-color: #958bfc;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
</p>
</div>
<div class="content-details">
<ion-label> <ion-label>
<p *ngIf="attachment.Assunto" class="attach-title-item">{{ attachment.Assunto }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p> <p>{{customDate}}</p>
<p *ngIf="!attachment.Assunto" class="attach-title-item">{{ attachment.DocNumber }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p> <p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) == toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">das {{loadedEvent.workflowInstanceDataFields.StartDate | date: 'HH:mm'}} às {{loadedEvent.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
<p><span class="span-left">{{attachment.Sender}}</span><span class="span-right">{{ attachment.DocDate | date: 'dd/MM/yy' }}</span></p> <p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) != toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">{{loadedEvent.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ loadedEvent.workflowInstanceDataFields.StartDate | date: 'dd/M/yy'}} </p>
<p *ngIf="loadedEvent.workflowInstanceDataFields.OccurrenceType == '-1'">(Não se repete)</p>
<p *ngIf="loadedEvent.workflowInstanceDataFields.OccurrenceType != '-1'">Repete</p>
</ion-label> </ion-label>
</ion-item> </div>
</ion-list> </div>
<div class="line"></div>
<div class="overflow-y-auto">
<div class="middle-content">
<div *ngIf="loadedEvent.workflowInstanceDataFields.ParticipantsList">
<h5>Intervenientes</h5>
<div *ngFor="let att of loadedEvent.workflowInstanceDataFields.ParticipantsList">
<ion-label>{{att.Name}}</ion-label>
</div>
<div class="line"></div>
</div>
<div *ngIf="loadedEvent.workflowInstanceDataFields.Body">
<h5>Detalhes</h5>
<ion-item lines="none" class="ion-no-margin ion-no-padding">
<p [innerHTML]="loadedEvent.workflowInstanceDataFields.Body"></p>
</ion-item>
<div class="line"></div>
</div>
</div>
<div *ngIf="loadedEvent.Documents" class="bottom-content width-100">
<ion-list>
<h5>Documentos Anexados</h5>
<ion-item class="ion-no-margin ion-no-padding cursor-pointer"
*ngFor="let attachment of loadedEvent.Documents"
(click)="viewDocument(attachment.DocId, attachment)">
<ion-label>
<p *ngIf="attachment.Assunto" class="attach-title-item">{{ attachment.Assunto }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p>
<p *ngIf="!attachment.Assunto" class="attach-title-item">{{ attachment.DocNumber }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p>
<p><span class="span-left">{{attachment.Sender}}</span><span class="span-right">{{ attachment.DocDate | date: 'dd/MM/yy' }}</span></p>
</ion-label>
</ion-item>
</ion-list>
</div>
</div> </div>
</div> </div>
</div>
<div *ngIf="loadedEvent" class="aside-right flex-column height-100">
<div *ngIf="loadedEvent" class="aside-right flex-column height-100"> <div class="aside-buttons">
<div class="aside-buttons"> <button hidden full class="btn-cancel" shape="round" >Editar evento</button>
<button hidden full class="btn-cancel" shape="round" >Editar evento</button> <button (click)="approveTask(loadedEvent.serialNumber)" full class="btn-cancel" shape="round" >Aprovar</button>
<button (click)="approveTask(loadedEvent.serialNumber)" full class="btn-cancel" shape="round" >Aprovar</button> <button (click)="emendTask(loadedEvent.serialNumber)" class="btn-cancel" shape="round" >Rever</button>
<button (click)="emendTask(loadedEvent.serialNumber)" class="btn-cancel" shape="round" >Rever</button> <div class="solid"></div>
<div class="solid"></div> <button full class="btn-cancel" shape="round" (click)="editar(loadedEvent.serialNumber)" >Editar</button>
<button full class="btn-cancel" shape="round" (click)="editar(loadedEvent.serialNumber)" >Editar</button> <button (click)="rejeitar(loadedEvent.serialNumber)" full class="btn-delete" shape="round" >Rejeitar</button>
<button (click)="rejeitar(loadedEvent.serialNumber)" full class="btn-delete" shape="round" >Rejeitar</button> </div>
</div> </div>
</div> </div>
+2
View File
@@ -17,6 +17,7 @@ export class AttachmentsService {
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
this.loggeduser = SessionStore.user this.loggeduser = SessionStore.user
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey); this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
} }
@@ -71,6 +72,7 @@ export class AttachmentsService {
headers: this.headers, headers: this.headers,
params: params params: params
}; };
return this.http.get<Attachment[]>(`${geturl}`, options); return this.http.get<Attachment[]>(`${geturl}`, options);
} }
+9 -4
View File
@@ -138,7 +138,7 @@ export class AuthService {
this.autoLoginChat(expirationDate.getTime() - date); this.autoLoginChat(expirationDate.getTime() - date);
} }
async autoLoginChat(expirationDate:number){ async autoLoginChat(expirationDate:number) {
setTimeout(()=>{ setTimeout(()=>{
this.loginChat(); this.loginChat();
}, expirationDate) }, expirationDate)
@@ -148,14 +148,18 @@ export class AuthService {
setTimeout(()=>{ setTimeout(()=>{
this.WsChatService.connect(); this.WsChatService.connect();
this.WsChatService.login().then((message) => { this.WsChatService.login().then((message: any) => {
console.log('rocket chat login successfully', message)
SessionStore.user.RochetChatUserId = message.result.id
SessionStore.save()
this.WsChatService.setStatus('online') this.WsChatService.setStatus('online')
}).catch((message)=>{
}).catch((message) => {
console.log('rocket chat login failed', message) console.log('rocket chat login failed', message)
}) })
// before sending a message with a attachment
this.NfService.beforeSendAttachment = async (message: MessageService, room?: RoomService) => { this.NfService.beforeSendAttachment = async (message: MessageService, room?: RoomService) => {
if(message.hasFile) { if(message.hasFile) {
@@ -225,6 +229,7 @@ export class AuthService {
return false return false
} }
}; };
}, 1) }, 1)
} }
+114 -129
View File
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { environment } from 'src/environments/environment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -15,156 +16,140 @@ export class ChatStorageService {
* @description delete message in the DB. get all messages, delete then corresponding message and update the store * @description delete message in the DB. get all messages, delete then corresponding message and update the store
* @param id message ID * @param id message ID
*/ */
private deleteMessageFromDb(messageId, roomId) { async deleteMessageFromDb(messageId, roomId) {
this.storage.get('chatmsg' + roomId).then((messages: any = []) => { if (environment.chatOffline) {
await this.storage.get('chatmsg' + roomId).then(async(messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
messages.forEach((message, index) => { await messages.forEach( async (message, index) => {
if(message._id == messageId) { if(message._id == messageId) {
messages.splice(index, 1) messages.splice(index, 1)
} }
}) })
this.storage.set('chatmsg' + roomId, messages).then((value) => { this.storage.set('chatmsg' + roomId, messages).then((value) => {
console.log('MSG SAVED ON STORAGE', value) console.log('MSG SAVED ON STORAGE', value)
}); });
})
}
}
async updateMessageDB(ChatMessage, roomId, identificator) {
if (environment.chatOffline) {
await this.storage.get('chatmsg' + roomId).then(async(messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
let index;
const find = messages.find((message, _index)=> {
if(message?.localReference == ChatMessage?.localReference ||
message?._id == ChatMessage?._id) {
index = _index
return true
}
return false
})
if(find) {
messages[index] = Object.assign(messages[index], ChatMessage)
await this.storage.set('chatmsg' + roomId, messages)
} else {
console.log('failed to update', identificator, ':',ChatMessage)
}
}) })
} }
}
getMsgFromDB() { async updateChat(history, roomId, identificator = '_id') {
if (environment.chatOffline) {
await this.storage.get('chatmsg' + roomId).then(async(messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
/* this.storage.get('chatmsg' + this.id).then((message) => { history.forEach( async(ChatMessage)=>{
console.log('ALL MESSAGE WEB', message) let index;
message.forEach(message => { const find = messages.find((message, _index)=> {
if (message.file) { if(message[identificator]) {
if (message.file.guid) { if(message[identificator] == ChatMessage[identificator]) {
this.storage.get(message.file.guid).then((image) => { index = _index
//console.log('IMAGE FROM STORAGE', image) return true
message.file.image_url = image }
}); }
}
} return false
})
let mmessage = this.fix_updatedAt(message)
console.log('FROM DB WEB', mmessage) if(find) {
const wewMessage = new MessageService(this.storage)
wewMessage.setData(mmessage)
this.messages.push(wewMessage) messages[index] = Object.assign(messages[index], ChatMessage)
console.log('loadHistory 222', this.messages)
}); // if(messages[index].msg.includes('***********')) {
}) */ // console.log('storage update')
} // console.log(JSON.stringify(messages[index]))
// console.log(JSON.stringify(ChatMessage))
// }
await this.storage.set('chatmsg' + roomId, messages)
} else {
console.log('failed to update', identificator)
}
})
async transformData(res) {
// this.mgsArray = [];
// res.forEach(async element => { })
// if (element.file) {
// if (element.file.guid) {
// await this.storage.get(element.file.guid).then((image) => {
// let chatmsg = {
// _id: element._id,
// attachments: element.attachments,
// channels: element.channels,
// file: {
// guid: element.file.guid,
// image_url: image,
// type: element.file.type
// },
// mentions: element.mentions,
// msg: element.msg,
// rid: element.rid,
// ts: element.ts,
// u: element.u,
// _updatedAt: element._updatedAt,
// }
// this.mgsArray.push(chatmsg);
// })
// } else {
// let chatmsg = {
// _id: element._id,
// attachments: element.attachments,
// channels: element.channels,
// file: element.file,
// mentions: element.mentions,
// msg: element.msg,
// rid: element.rid,
// ts: element.ts,
// u: element.u,
// _updatedAt: element._updatedAt,
// }
// this.mgsArray.push(chatmsg)
// }
// } else {
// let chatmsg = {
// _id: element._id,
// attachments: element.attachments,
// channels: element.channels,
// mentions: element.mentions,
// msg: element.msg,
// rid: element.rid,
// ts: element.ts,
// u: element.u,
// _updatedAt: element._updatedAt,
// }
// this.mgsArray.push(chatmsg)
// }
// });
// await this.storage.remove('chatmsg').then(() => {
// console.log('MSG REMOVE FROM STORAGE')
// });
// await this.storage.set('chatmsg', this.mgsArray).then((value) => {
// console.log('MSG SAVED ON STORAGE', value)
// });
} }
}
async addMessageDB(ChatMessage, roomId) {
if (environment.chatOffline) {
await this.storage.get('chatmsg' + roomId).then(async(messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
getMsgFromDBMobile() {
// console.log('ALL MSG DBBB', this.id) if(!ChatMessage._id && environment.chatOffline) {
// this.sqlservice.getAllChatMSG(this.id).then((msg: any = []) => {
// let ad = []; delete ChatMessage.temporaryData
// ad = msg messages.push(ChatMessage)
// console.log('ALL MSG DBBB', ad.length)
// msg.map(element => { await this.storage.set('chatmsg' + roomId, messages)
// console.log('CHANNEL ELEMENT', element) console.log('add to DB', ChatMessage)
// let msgChat = {
// _id: element.Id, } else {
// attachments: this.isJson(element.Attachments), const find = messages.find((message)=> {
// channels: this.isJson(element.Channels), return message._id == ChatMessage._id
// file: { })
// guid: this.isJson(element.File).guid,
// image_url: this.isJson(element.image_url), if(!find) {
// type: this.isJson(element.File).type delete ChatMessage.temporaryData
messages.push(ChatMessage)
// }, await this.storage.set('chatmsg' + roomId, messages)
// mentions: this.isJson(element.Mentions), console.log('add to DB', ChatMessage)
// msg: element.Msg, }
// rid: element.Rid,
// ts: element.Ts, }
// u: this.isJson(element.U), })
// _updatedAt: this.isJson(element.UpdatedAt),
// }
// let mmessage = this.fix_updatedAt(msgChat)
// console.log('FROM DB WEB', mmessage)
// const wewMessage = new MessageService(this.storage)
// wewMessage.setData(mmessage)
// this.messages.push(wewMessage)
// console.log('loadHistory 222', this.messages)
// });
// });
} }
}
} }
+105 -48
View File
@@ -7,6 +7,8 @@ import { NfService } from 'src/app/services/chat/nf.service'
import { WsChatService } from 'src/app/services/chat/ws-chat.service'; import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { showDateDuration } from 'src/plugin/showDateDuration'; import { showDateDuration } from 'src/plugin/showDateDuration';
import { ChatStorageService } from './chat-storage.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@@ -26,7 +28,7 @@ export class MessageService {
} }
t = '' t = ''
_id ='' _id = ''
_updatedAt _updatedAt
file file
attachments attachments
@@ -44,13 +46,16 @@ export class MessageService {
viewed = [] viewed = []
received = [] received = []
messageSend = false
constructor(private storage: Storage, constructor(private storage: Storage,
private NfService: NfService, private NfService: NfService,
private WsChatService: WsChatService) { private WsChatService: WsChatService,
private ChatStorageService: ChatStorageService) {
} }
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments, temporaryData, localReference}:Message) { setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments, temporaryData, localReference , viewed = [], received = []}:Message) {
this.customFields = customFields
this.channels = channels || [] this.channels = channels || []
this.mentions = mentions || [] this.mentions = mentions || []
this.msg = msg || "" this.msg = msg || ""
@@ -65,9 +70,23 @@ export class MessageService {
this.temporaryData = temporaryData this.temporaryData = temporaryData
this.localReference = localReference || null this.localReference = localReference || null
if(this.msg.includes('***********')) {
console.log('-=-=--=-=-=',JSON.stringify(viewed), JSON.stringify(this.viewed))
}
this.viewed = [...new Set([...viewed,...this.viewed])];
this.received = [...new Set([...received,...this.received])];
if(this.msg.includes('***********')) {
console.log('-=-=--=-=-=',JSON.stringify(viewed), JSON.stringify(this.viewed))
}
if(!this.ts) { if(!this.ts) {
this.offline = true this.offline = true
this.messageSend = false
} else { } else {
this.messageSend = true
this.offline = false this.offline = false
} }
@@ -79,10 +98,6 @@ export class MessageService {
} }
} }
// if(typeof(this.file?.type)) {
// this.hasFile = true
// }
if(this.hasFile) { if(this.hasFile) {
this.getFileFromDb() this.getFileFromDb()
if(this.file.type != 'application/webtrix') { if(this.file.type != 'application/webtrix') {
@@ -90,7 +105,6 @@ export class MessageService {
} }
} }
this.calDateDuration() this.calDateDuration()
} }
@@ -121,10 +135,11 @@ export class MessageService {
if(!this.hasFile) { if(!this.hasFile) {
this.WsChatService.send({roomId:this.rid, msg:this.msg, localReference: this.localReference}).then(({message, requestId}) => { this.WsChatService.send({roomId:this.rid, msg:this.msg, localReference: this.localReference}).then(({message, requestId}) => {
let ChatMessage = message.result let ChatMessage = message.result
this.messageSend = true
this.redefinedMessage(ChatMessage)
if (environment.chatOffline) { if (environment.chatOffline) {
// this.redefinedMessage(ChatMessage)
this.offline = false this.offline = false
} }
@@ -151,17 +166,21 @@ export class MessageService {
this.WsChatService.send({roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file, localReference: this.localReference}).then(({message, requestId}) => { this.WsChatService.send({roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file, localReference: this.localReference}).then(({message, requestId}) => {
console.log('message', message)
let ChatMessage = message.result let ChatMessage = message.result
this.messageSend = true
this.redefinedMessage(ChatMessage)
if (environment.chatOffline) { if (environment.chatOffline) {
// this.redefinedMessage(ChatMessage)
this.offline = false this.offline = false
} }
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
resolve(ChatMessage) resolve(ChatMessage)
}) })
}) })
} else if(this.WsChatService.isLogin == false) { } else if(this.WsChatService.isLogin == false) {
@@ -185,12 +204,39 @@ export class MessageService {
} }
redefinedMessage(ChatMessage) { async redefinedMessage(ChatMessage , update = true) {
ChatMessage = this.NfService.fix_updatedAt(ChatMessage) ChatMessage = this.NfService.fix_updatedAt(ChatMessage)
let reference
if(this._id) {
reference = '_id'
} else {
reference = 'localReference'
}
const message = this.getChatObj()
// const viewed = [...new Set([...ChatMessage.viewed,...this.viewed])];
// const received = [...new Set([...ChatMessage.received,...this.received])];
// if(ChatMessage.msg.includes('***********')) {
// console.log('redefinedMessage')
// console.log(JSON.stringify(ChatMessage))
// console.log(JSON.stringify(message))
// console.log(JSON.stringify(Object.assign(message, ChatMessage)))
// }
ChatMessage = Object.assign(message, ChatMessage)
if(update) {
await this.ChatStorageService.updateMessageDB(ChatMessage, this.rid, reference)
}
this.setData(ChatMessage) this.setData(ChatMessage)
} }
async downloadFileMsg() { async downloadFileMsg() {
const result = await this.NfService.beforeSendAttachment(this) const result = await this.NfService.beforeSendAttachment(this)
if(result) { if(result) {
@@ -207,43 +253,54 @@ export class MessageService {
return this.u.username != SessionStore.user.RochetChatUser return this.u.username != SessionStore.user.RochetChatUser
} }
receptorReceive() { async delete() {
await this.ChatStorageService.deleteMessageFromDb(this._id, this.rid)
if(this.messageReceptor()) {
let newMessage = {
rid: this._id,
msg: this.msg,
attachments: this.attachments,
file: this.file,
localReference: this.localReference,
viewed: this.viewed.push('123'),
received: this.viewed.push('123'),
}
this.WsChatService.updateMessage(newMessage).then(()=>{
console.log('newMessage', newMessage)
})
}
} }
receptorView() { isSenderIsNotMe(ChatMessage) {
if(this.messageReceptor()) { return SessionStore.user.RochetChatUser != ChatMessage.u.username
let newMessage = { }
rid: this._id,
msg: this.msg, messageOwnerById(id) {
attachments: this.attachments, return SessionStore.user.RochetChatUser != this.u.username
file: this.file, }
localReference: this.localReference,
viewed: this.viewed.push('123'), private getChatObj() {
received: this.viewed.push('123'), return {
} channels: this.channels,
mentions: this.mentions,
this.WsChatService.updateMessage(newMessage).then(()=>{ msg: this.msg,
console.log('newMessage', newMessage) rid: this.rid,
}) ts: this.ts,
u: this.u,
_id: this._id,
_updatedAt: this._updatedAt,
messageSend: this.messageSend,
offline: this.offline,
viewed: this.viewed,
received: this.received,
localReference: this.localReference
}
}
async addMessageDB() {
const message = this.getChatObj()
await this.ChatStorageService.addMessageDB(message, this.rid)
}
async save() {
const message = this.getChatObj()
let reference
if(this._id) {
reference = '_id'
} else {
reference = 'localReference'
} }
await this.ChatStorageService.updateMessageDB(message, this.rid, reference)
} }
} }
+218 -190
View File
@@ -16,6 +16,7 @@ import { environment } from 'src/environments/environment';
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { NfService } from 'src/app/services/chat/nf.service'; import { NfService } from 'src/app/services/chat/nf.service';
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { ChatStorageService } from './chat-storage.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -32,6 +33,7 @@ export class RoomService {
name = '' name = ''
_updatedAt = {} _updatedAt = {}
hasLoadHistory = false hasLoadHistory = false
restoreFromOffline = false
duration = '' duration = ''
isTyping = false isTyping = false
otherUserType = false otherUserType = false
@@ -39,10 +41,10 @@ export class RoomService {
message = '' message = ''
lastMessageTxt = '' lastMessageTxt = ''
userThatIsTyping = '' userThatIsTyping = ''
private ToastService = ToastsService
mgsArray = []; mgsArray = [];
messagesLocalReference = [] messagesLocalReference = []
members = []
u
scrollDown = () => { } scrollDown = () => { }
@@ -66,21 +68,60 @@ export class RoomService {
private NativeNotificationService: NativeNotificationService, private NativeNotificationService: NativeNotificationService,
private sortService: SortService, private sortService: SortService,
private chatService: ChatService, private chatService: ChatService,
private NfService: NfService private NfService: NfService,
private ChatStorageService: ChatStorageService
) { ) {
this.NativeNotificationService.askForPermission() this.NativeNotificationService.askForPermission()
this.restoreMessageFromDB()
this.WsChatService.getUserStatus((d) => {
const userId = d.fields.args[0][0]
if(this.members?.map) {
const membersIds = this.members.map((user)=> user._id)
if(membersIds.includes(userId)) {
this.messages.forEach((message, index) => {
if(!message.messageOwnerById(userId)) {
if(!this.messages[index]?.received?.includes(userId)) {
if(this.messages[index]._id) {
try {
this.messages[index].received.push(userId)
} catch(e) {
this.messages[index].received = [userId]
}
this.messages[index].save()
}
}
}
})
}
}
})
} }
setData({ customFields = {}, id, name, t, lastMessage = new MessageService(this.storage, this.NfService, this.WsChatService), _updatedAt }) { setData({members, u, customFields = {}, id, name, t, lastMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService), _updatedAt }) {
this.customFields = customFields this.customFields = customFields
this.id = id this.id = id
this.name = name this.name = name
this.t = t this.t = t
this.lastMessage = lastMessage this.lastMessage = lastMessage
this._updatedAt = _updatedAt this._updatedAt = _updatedAt
this.u = u
this.members = members
this.calDateDuration() this.calDateDuration()
this.restoreMessageFromDB() this.restoreMessageFromDB()
} }
@@ -89,19 +130,26 @@ export class RoomService {
return SessionStore.user.RochetChatUser != ChatMessage.u.username return SessionStore.user.RochetChatUser != ChatMessage.u.username
} }
senderId(ChatMessage) {
return ChatMessage.u._id
}
receiveMessage() { receiveMessage() {
this.WsChatService.updateRoomEventss( this.WsChatService.updateRoomEventss(
this.id, this.id,
"stream-room-messages", "stream-room-messages",
(_ChatMessage) => { async (_ChatMessage) => {
console.log('recivemessage', _ChatMessage) console.log('recivemessage', _ChatMessage)
let ChatMessage = _ChatMessage.fields.args[0] let ChatMessage = _ChatMessage.fields.args[0]
ChatMessage = this.fix_updatedAt(ChatMessage) ChatMessage = this.fix_updatedAt(ChatMessage)
if(!this.messagesLocalReference.includes(ChatMessage.localReference)) { if(!this.messagesLocalReference.includes(ChatMessage.localReference)) {
const message = this.prepareMessage(ChatMessage)
const message = await this.prepareMessage({message: ChatMessage, save: true})
message.messageSend = true
this.lastMessage = message this.lastMessage = message
this.calDateDuration(ChatMessage._updatedAt) this.calDateDuration(ChatMessage._updatedAt)
@@ -114,154 +162,63 @@ export class RoomService {
message: message.msg, message: message.msg,
title: this.name title: this.name
}); });
} }
this.addMessageDB(ChatMessage) message.addMessageDB()
setTimeout(()=>{ setTimeout(()=>{
this.scrollDown() this.scrollDown()
}, 50) }, 50)
} } else {
this.messages.forEach((message, index)=> {
if(message.localReference == ChatMessage.localReference) {
const membersIds = this.members.map((user)=> user._id)
this.getAllUsers().forEach( async (users) => {
if(membersIds.includes(users._id)) {
if(users.status != 'offline') {
this.messages[index].received.push(users._id)
setTimeout(() => {
message.save()
}, 150)
}
}
});
}
})
}
} }
) )
this.WsChatService.receiveStreamNotifyRoom((message) => { this.WsChatService.receiveStreamNotifyRoom((message) => {
if(message.fields.eventName == this.id+'/'+'typing') { if(message.fields.eventName == this.id+'/'+'typing') {
this.userThatIsTyping = this.usernameToDisplayName(message.fields.args[0]) const args = message.fields.args
console.log(this.userThatIsTyping, 'this.userThatIsTyping') if (typeof args[0] != 'object') {
this.isTyping = message.fields.args[1] this.userThatIsTyping = this.usernameToDisplayName(args[0])
this.otherUserType = message.fields.args[1] console.log(this.userThatIsTyping, 'this.userThatIsTyping')
this.isTyping = args[1]
this.otherUserType = args[1]
this.readAllMessage()
} else {
this.readAllMessage()
}
} else if (message.fields.eventName == this.id+'/'+'deleteMessage') {} } else if (message.fields.eventName == this.id+'/'+'deleteMessage') {}
}) })
} }
async addMessageDB(ChatMessage) {
if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
if(!ChatMessage._id && environment.chatOffline) {
delete ChatMessage.temporaryData
messages.push(ChatMessage)
this.storage.set('chatmsg' + this.id, messages)
} else {
const find = messages.find((message)=> {
return message._id == ChatMessage._id
})
if(!find) {
delete ChatMessage.temporaryData
messages.push(ChatMessage)
this.storage.set('chatmsg' + this.id, messages)
}
}
})
}
}
async updateMessageDB(ChatMessage, localReference) {
if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
let index;
const find = messages.find((message, _index)=> {
if(message.localReference) {
if(message?.localReference == ChatMessage?.localReference) {
index = _index
return true
}
}
return false
})
if(find) {
messages[index] = ChatMessage
this.storage.set('chatmsg' + this.id, messages)
}
})
}
}
async updateViewedMessage(id, userId) {
if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
let index;
const find = messages.find((message, _index)=> {
if(message._id == id) {
index = _index
return true
}
return false
})
if(find) {
if(!messages[index].hasOwnProperty('viewed') || !Array.isArray(messages[index].viewed)) {
messages.viewed = []
}
messages.viewed.push(userId)
this.storage.set('chatmsg' + this.id, messages)
}
})
}
}
/**
* @description delete message in the DB. get all messages, delete then corresponding message and update the store
* @param id message ID
*/
private deleteMessageFromDb(id) {
if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
messages.forEach((message, index) => {
if(message._id == id) {
messages.splice(index, 1)
}
})
this.storage.set('chatmsg' + this.id, messages).then((value) => {
console.log('MSG SAVED ON STORAGE', value)
});
})
}
}
async receiveMessageDelete() { async receiveMessageDelete() {
@@ -286,9 +243,10 @@ export class RoomService {
deleteMessage(id) { deleteMessage(id) {
this.messages.forEach((message, index) => { this.messages.forEach((message, index) => {
if(message._id == id) { if(message._id == id) {
this.messages.splice(index, 1) this.messages.splice(index, 1)
message.delete()
this.deleteMessageFromDb(id)
//Get previous last message from room //Get previous last message from room
const previousLastMessage = this.messages.slice(-1)[0]; const previousLastMessage = this.messages.slice(-1)[0];
@@ -298,6 +256,7 @@ export class RoomService {
} }
}) })
} }
@@ -314,24 +273,17 @@ export class RoomService {
attachments, attachments,
file, file,
temporaryData, temporaryData,
localReference, localReference
viewed: [],
received: []
} }
const message: MessageService = await this.prepareMessage({message:offlineChatMessage, save: environment.chatOffline})
const message: MessageService = this.prepareMessage(offlineChatMessage, environment.chatOffline) this.messagesLocalReference.push(localReference)
await message.addMessageDB()
/** message.send()
* @description redefine message offline data "offlineChatMessage" with live ChatMessage
*/
message.send().then((ChatMessage) => {
this.updateMessageDB(ChatMessage, localReference)
})
if (environment.chatOffline) { if (environment.chatOffline) {
this.messagesLocalReference.push(localReference)
this.addMessageDB(offlineChatMessage)
setTimeout(() => { setTimeout(() => {
this.scrollDown() this.scrollDown()
@@ -346,25 +298,6 @@ export class RoomService {
} }
/**
*
* @param message
* @param ChatMessage
* @description when creating message we use offline data, then we need redefined with live data
*/
redefinedMessage (message: MessageService, ChatMessage) {
ChatMessage = this.fix_updatedAt(ChatMessage)
message.setData(ChatMessage)
if( new Date(this.lastMessage._updatedAt).getTime() < new Date(message._updatedAt).getTime()) {
this.lastMessage = message
this.calDateDuration(message._updatedAt)
}
this.sortRoomList()
}
sendTyping(text:string = this.message) { sendTyping(text:string = this.message) {
@@ -387,6 +320,10 @@ export class RoomService {
this.typingWatch() this.typingWatch()
} }
sendFalseTypingReadMessage() {
this.WsChatService.sendStreamNotifyRoom(this.id, SessionStore.user.RochetChatUser, 'typing', {})
this.setTypingOff()
}
private typingWatch() { private typingWatch() {
setTimeout(()=>{ setTimeout(()=>{
@@ -440,19 +377,25 @@ export class RoomService {
messages = [] messages = []
} }
// console.log('offline messages', messages)
await messages.forEach( async (ChatMessage, index) => { await messages.forEach( async (ChatMessage, index) => {
const wewMessage = this.prepareMessage(ChatMessage, false)
// if(ChatMessage.msg.includes('***********')) {
// console.log('restore ========')
// console.log(JSON.stringify(ChatMessage))
// }
const wewMessage = await this.prepareMessage({message:ChatMessage, save: false})
if(wewMessage.offline == false) { if(wewMessage.offline == false) {
this.prepareMessage(ChatMessage) this.prepareMessage(ChatMessage)
} else { } else {
const offlineMessage = this.prepareMessage(ChatMessage) const offlineMessage = await this.prepareMessage({message:ChatMessage, save: true})
this.messagesLocalReference.push(offlineMessage.localReference) this.messagesLocalReference.push(offlineMessage.localReference)
offlineMessage.send().then((newChatMessage) => { // offlineMessage.send()
this.updateMessageDB(newChatMessage, ChatMessage.localReference)
})
} }
}); });
@@ -467,7 +410,7 @@ export class RoomService {
} }
// runs onces only // runs onces only
async loadHistory({limit = 50, forceUpdate = false }) { async loadHistory({limit = 10000000, forceUpdate = false }) {
if(forceUpdate == false) { if(forceUpdate == false) {
if (this.hasLoadHistory) { if (this.hasLoadHistory) {
@@ -475,15 +418,23 @@ export class RoomService {
} }
} }
if(this.restoreFromOffline == false) {
this.restoreFromOffline = true
await this.restoreMessageFromDB()
}
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => { await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
await chatHistory.result.messages.reverse().forEach( async (message) => { await chatHistory.result.messages.reverse().forEach( async (message) => {
this.prepareMessage(message) // await this.prepareMessage({message})
// this.messages = this.sortService.sortDate(this.messages, '_updatedAt')
}) })
// console.log('load history ',chatHistory)
await this.readMessage(chatHistory)
//await this.updateAllMessages()
this.storage.set('chatmsg' + this.id, chatHistory.result.messages) this.storage.set('chatmsg' + this.id, chatHistory.result.messages)
}) })
@@ -494,6 +445,72 @@ export class RoomService {
this.hasLoadHistory = true this.hasLoadHistory = true
} }
async readMessage(chatHistory) {
const firstUnread = chatHistory.result.firstUnread
let foundUnread = false
// if (chatHistory.result.unreadNotLoaded == 0) {
// const membersIds = this.members.map((user)=> user._id)
// this.messages.forEach((message, index) => {
// if(message.viewed.length == 0) {
// this.messages[index].viewed = membersIds
// }
// })
// } else {
// chatHistory.result.messages.forEach((message) => {
// console.log(message._id == firstUnread._id)
// if(message._id == firstUnread._id) {
// foundUnread = true
// console.log('found=============================')
// } else {
// console.log('message')
// }
// });
// }
}
async readAllMessage() {
const membersIds = this.members.map((user)=> user._id)
await this.messages.forEach( async (message, index) => {
if(message._id) {
if(message.viewed.length == 0) {
this.messages[index].viewed = membersIds
this.messages[index].received = membersIds
}
}
})
this.updateAllMessages()
}
updateAllMessages () {
const newHistory = this.messages.map((message) => {
return {
channels: message.channels,
mentions: message.mentions,
msg: message.msg,
rid: message.rid,
ts: message.ts,
u: message.u,
_id: message._id,
_updatedAt: message._updatedAt,
messageSend: message.messageSend,
offline: message.offline,
viewed: message.viewed,
received: message.received
}
})
this.ChatStorageService.updateChat(newHistory, this.id)
}
/** /**
* @description find or create message * @description find or create message
@@ -501,32 +518,40 @@ export class RoomService {
* @param save * @param save
* @returns * @returns
*/ */
prepareMessage(message, save = true): MessageService { async prepareMessage({message, save = true, redefined = false}): Promise<MessageService> {
message = this.fix_updatedAt(message) message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService)
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService)
wewMessage.setData(message) wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory wewMessage.loadHistory = this.hasLoadHistory
if(!message._id && environment.chatOffline && save) { if(!message?._id && environment.chatOffline && save) {
this.messages.push(wewMessage) this.messages.push(wewMessage)
return wewMessage return wewMessage
} }
const found = this.messages.find((MessageService) => { let foundIndex;
const found = this.messages.find((MessageService, index) => {
if (MessageService._id == message._id) { if (MessageService._id == message._id) {
if(this.hasLoadHistory) console.log(`${MessageService._id} == ${message._id}`) foundIndex = index
return true return true
} else { } else {
return false return false
} }
}) })
if (save && !found) { if (save || !found) {
this.messages.push(wewMessage) this.messages.push(wewMessage)
return wewMessage
} else{
if(redefined) {
}
return this.messages[foundIndex]
} }
return wewMessage
} }
private calDateDuration(date = null) { private calDateDuration(date = null) {
@@ -534,11 +559,10 @@ export class RoomService {
this._updatedAt = date || this._updatedAt this._updatedAt = date || this._updatedAt
} }
private fix_updatedAt(message) { private fix_updatedAt(message) {
if (message.result) { if (message?.result) {
message.result._updatedAt = message.result._updatedAt['$date'] message.result._updatedAt = message.result._updatedAt['$date']
} else if(message._updatedAt) { } else if(message?._updatedAt) {
if(message._updatedAt.hasOwnProperty('$date')) { if(message._updatedAt.hasOwnProperty('$date')) {
message._updatedAt = message._updatedAt['$date'] message._updatedAt = message._updatedAt['$date']
} }
@@ -546,7 +570,6 @@ export class RoomService {
return message return message
} }
usernameToDisplayName(username) { usernameToDisplayName(username) {
const firstName = capitalizeTxt(username.split('.')[0]) const firstName = capitalizeTxt(username.split('.')[0])
@@ -554,4 +577,9 @@ export class RoomService {
return firstName + ' ' + lastName return firstName + ' ' + lastName
} }
sendReadMessage() {
this.WsChatService.readMessage(this.id)
this.sendFalseTypingReadMessage()
}
} }
@@ -14,6 +14,10 @@ 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 { UserSession } from 'src/app/models/user.model';
import { AuthService } from '../auth.service';
import { ChatStorageService } from './chat-storage.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@@ -33,6 +37,8 @@ export class WsChatMethodsService {
currentRoom: RoomService = null currentRoom: RoomService = null
users: chatUser[] = [] users: chatUser[] = []
loggedUser: any;
constructor( constructor(
private WsChatService: WsChatService, private WsChatService: WsChatService,
private storage: Storage, private storage: Storage,
@@ -43,8 +49,13 @@ export class WsChatMethodsService {
private ChatService: ChatService, private ChatService: ChatService,
private NfService: NfService, private NfService: NfService,
private changeProfileService: ChangeProfileService, private changeProfileService: ChangeProfileService,
private chatService: ChatService,
private authService: AuthService,
private ChatStorageService: ChatStorageService
) { ) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.loadChat() this.loadChat()
this.WsChatService.registerCallback({ this.WsChatService.registerCallback({
@@ -79,39 +90,6 @@ export class WsChatMethodsService {
this.storage.remove('Rooms'); this.storage.remove('Rooms');
}) })
// this.WsChatService.registerCallback({
// type:'Onmessage',
// funx:(message) => {
// if(message.msg =='changed' && message.collection == "stream-room-messages") {
// if(message.fields.args[0].rid) {
// // new message
// const ChatMessage = message.fields.args[0]
// const messageId = ChatMessage.rid
// setTimeout(()=>{
// this.sortRoomList()
// }, 100)
// }
// } else if(message.msg =='changed' && message.collection == "stream-notify-room") {
// if(message.fields.eventName.includes('deleteMessage')) {
// // delete message
// const DeletedMessageId = message.fields.args[0]._id;
// setTimeout(()=>{
// this.sortRoomList()
// }, 100)
// } else if(message.fields.eventName.includes('typing')) {
// }
// }
// }
// })
} }
private loadChat() { private loadChat() {
@@ -144,7 +122,6 @@ export class WsChatMethodsService {
this.users = [] this.users = []
} }
openRoom(roomId) { openRoom(roomId) {
if(this.currentRoom) { if(this.currentRoom) {
@@ -161,7 +138,6 @@ export class WsChatMethodsService {
} }
async restoreRooms() { async restoreRooms() {
try { try {
@@ -183,14 +159,46 @@ export class WsChatMethodsService {
this.loadingWholeList = true this.loadingWholeList = true
const rooms = await this.WsChatService.getRooms(); const rooms = await this.WsChatService.getRooms();
await this.storage.remove('Rooms'); await this.storage.remove('Rooms');
await this.storage.set('Rooms', rooms);
console.log('rooms', rooms)
await rooms.result.update.forEach( async (roomData: room) => { console.log('rooms ============', rooms)
await this.prepareRoom(roomData);
await rooms.result.update.forEach( async (roomData: room, index) => {
const roomId = this.getRoomId(roomData);
if(roomData.t == 'd') {
const res = await this.chatService.getMembers(roomId).toPromise();
const members = res['members'];
const users = members.filter(data => data.username != this.loggedUser.me.username);
rooms.result.update[index]['members'] = users
await this.prepareRoom(roomData);
} else {
if (roomData.t === 'p') {
const res = await this.chatService.getGroupMembers(roomId).toPromise()
const members = res['members'];
const users = members.filter(data => data.username != this.loggedUser.me.username);
rooms.result.update[index]['members'] = users
}
else {
const res = await this.chatService.getChannelMembers(roomId).toPromise()
const members = res['members'];
const users = members.filter(data => data.username != this.loggedUser.me.username);
rooms.result.update[index]['members'] = users
}
}
}); });
await this.storage.set('Rooms', rooms);
console.log(rooms.result.update, 'rooms.result.update')
this.sortRoomList() this.sortRoomList()
this.loadingWholeList = false this.loadingWholeList = false
} }
@@ -247,6 +255,8 @@ export class WsChatMethodsService {
}) })
this.WsChatService.subStreamNotifyRoom(id, 'typing', false) this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
this.WsChatService.subStreamNotifyRoom(id, 'readMessage', false)
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{ this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
//console.log('streamNotifyRoomDeleteMessage', subscription); //console.log('streamNotifyRoomDeleteMessage', subscription);
}) })
@@ -269,14 +279,16 @@ export class WsChatMethodsService {
name: this.getRoomName(roomData), name: this.getRoomName(roomData),
t: roomData.t, t: roomData.t,
lastMessage: this.getRoomLastMessage(roomData), lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date']) _updatedAt: new Date(roomData._updatedAt['$date']),
u : roomData.u || {},
members: roomData.members
} }
let roomId = this.getRoomId(roomData) let roomId = this.getRoomId(roomData)
// create room // create room
if(!this.roomExist(roomId)) { if(!this.roomExist(roomId)) {
let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService) let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService , this.ChatStorageService)
room.setData(setData) room.setData(setData)
room.receiveMessage() room.receiveMessage()
room.getAllUsers = this.getUsers room.getAllUsers = this.getUsers
@@ -300,7 +312,6 @@ export class WsChatMethodsService {
} }
} else { } else {
console.log('have!!!')
// in this case room is already present, therefor it will only be necessary, // in this case room is already present, therefor it will only be necessary,
// to redefine // to redefine
@@ -336,16 +347,16 @@ export class WsChatMethodsService {
const username = d.fields.args[0][1] const username = d.fields.args[0][1]
const statusNum = d.fields.args[0][2] const statusNum = d.fields.args[0][2]
const statusText = this.statusNumberToText(statusNum) const statusText = this.statusNumberToText(statusNum)
const user = this.getUserByName(username) this.users.forEach((user, index) => {
if(user.username == username) {
if(user) { this.users[index].status = statusText
user.status = statusText }
} })
}) })
} }
getUserByName(username) { getUserByName(username) {
@@ -460,9 +471,9 @@ export class WsChatMethodsService {
let _res = await this.ChatService.getAllUsers().toPromise() let _res = await this.ChatService.getAllUsers().toPromise()
let user = _res['users'].filter(data => data.username != SessionStore.user.RochetChatUser); let users = _res['users'].filter(data => data.username != SessionStore.user.RochetChatUser);
user = user.sort((a,b) => { users = users.sort((a,b) => {
if(a.name < b.name) { if(a.name < b.name) {
return -1; return -1;
} }
@@ -472,7 +483,11 @@ export class WsChatMethodsService {
return 0; return 0;
}); });
this.users = user users.forEach((user, index) => {
// user[index].status = this.statusNumberToText(user[index].status)
})
this.users = users
} }
getUserOfRoom(roomId){ getUserOfRoom(roomId){
+29 -4
View File
@@ -123,6 +123,30 @@ export class WsChatService {
}); });
} }
readMessage(roomId) {
const requestId = uuidv4()
const message = {
"msg":"method",
"method":"readMessages",
"params": [roomId, []],
"id": requestId
}
this.ws.send({message, requestId})
return new Promise<Rooms>((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId) { // same request send
resolve(message)
return true
}
}})
});
}
getUserOfRoom(roomId) { getUserOfRoom(roomId) {
const requestId = uuidv4() const requestId = uuidv4()
@@ -174,6 +198,8 @@ export class WsChatService {
}] }]
} }
console.log('send message to rocketchat ', message)
this.ws.send({message, requestId}); this.ws.send({message, requestId});
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@@ -285,7 +311,7 @@ export class WsChatService {
}); });
} }
joinRoom(){} joinRoom() {}
deleteMessage(msgId) { deleteMessage(msgId) {
const requestId = uuidv4(); const requestId = uuidv4();
@@ -369,7 +395,7 @@ export class WsChatService {
} }
subStreamNotifyRoom(roomId : string , event: 'typing' | 'deleteMessage', param: any) { subStreamNotifyRoom(roomId : string , event: 'typing' | 'deleteMessage' | 'readMessage', param: any) {
const requestId = uuidv4() const requestId = uuidv4()
@@ -496,7 +522,7 @@ export class WsChatService {
} }
updateRoomEventss(roomId, collection:string, funx: Function, ) { updateRoomEventss(roomId, collection:string, funx: Function, ) {
this.ws.registerCallback({ this.ws.registerCallback({
type:'Onmessage', type:'Onmessage',
@@ -515,7 +541,6 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
}) })
} }
streamRoomMessages(roomId : string) { streamRoomMessages(roomId : string) {
const requestId = uuidv4() const requestId = uuidv4()
@@ -27,114 +27,118 @@
</div> </div>
</div> </div>
<div class="content d-flex flex-column">
<div class="header-content width-100 d-flex justify-space-between"> <div class="main-content d-flex height-100 width-100">
<div (click)="close()" class="header-icon-left cursor-pointer"> <div class="content d-flex flex-column">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-arrow-arrow-left.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-calendar-arrow-left.svg"></ion-icon>
</div>
<div class="header-title flex-grow-1 cursor-pointer">
<label>{{loadedEvent.workflowInstanceDataFields.Subject}}</label>
</div>
<div (click)="editar(loadedEvent.serialNumber)" class="header-icon-right display-none-{{showAside}}"> <div class="header-content width-100 d-flex justify-space-between">
<button class="btn-no-color"> <div (click)="close()" class="header-icon-left cursor-pointer">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-edit.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-arrow-arrow-left.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-edit.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-calendar-arrow-left.svg"></ion-icon>
</button>
</div>
<div (click)="rejectTask(loadedEvent.serialNumber)" class="header-icon-right display-none-{{showAside}}">
<button class="btn-no-color" >
<ion-icon class="delete" name="trash-sharp"></ion-icon>
</button>
</div>
</div>
<div class="upper-content d-flex flex-column">
<div class="content-location">
<p>
<span class="location">{{loadedEvent.workflowInstanceDataFields.Location}}</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial MDGPR' " style="background-color: #ffb703;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal MDGPR' " style="background-color: #f05d5e;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial PR' " style="background-color: #99e47b;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal PR' " style="background-color: #958bfc;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
</p>
</div>
<div class="content-details">
<ion-label>
<p>{{customDate}}</p>
<p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) == toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">das {{loadedEvent.workflowInstanceDataFields.StartDate | date: 'HH:mm'}} às {{loadedEvent.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
<p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) != toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">{{loadedEvent.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ loadedEvent.workflowInstanceDataFields.StartDate | date: 'dd/M/yy'}} </p>
<p *ngIf="!loadedEvent.workflowInstanceDataFields.IsRecurring">(Não se repete)</p>
<p *ngIf="loadedEvent.workflowInstanceDataFields.IsRecurring">Repete</p>
</ion-label>
</div>
</div>
<div class="line"></div>
<div class="overflow-y-auto">
<div class="middle-content">
<div *ngIf="loadedEvent.workflowInstanceDataFields.ParticipantsList">
<h5>Intervenientes</h5>
<div *ngFor="let att of loadedEvent.workflowInstanceDataFields.ParticipantsList">
<ion-label>{{att.Name}}</ion-label>
</div>
<div class="line"></div>
</div> </div>
<div *ngIf="loadedEvent.workflowInstanceDataFields.Body"> <div class="header-title flex-grow-1 cursor-pointer">
<h5>Detalhes</h5> <label>{{loadedEvent.workflowInstanceDataFields.Subject}}</label>
<ion-item lines="none" class="ion-no-margin ion-no-padding">
<p [innerHTML]="loadedEvent.workflowInstanceDataFields.Body"></p>
</ion-item>
<div class="line"></div>
</div> </div>
<div (click)="editar(loadedEvent.serialNumber)" class="header-icon-right display-none-{{showAside}}">
<button class="btn-no-color">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-edit.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-edit.svg"></ion-icon>
</button>
</div>
<div (click)="rejectTask(loadedEvent.serialNumber)" class="header-icon-right display-none-{{showAside}}">
<button class="btn-no-color" >
<ion-icon class="delete" name="trash-sharp"></ion-icon>
</button>
</div>
</div> </div>
<div class="upper-content d-flex flex-column">
<div *ngIf="loadedEvent.Documents" class="bottom-content width-100"> <div class="content-location">
<ion-list> <p>
<h5>Documentos Anexados </h5> <span class="location">{{loadedEvent.workflowInstanceDataFields.Location}}</span>
<ion-item class="ion-no-margin ion-no-padding cursor-pointer"
*ngFor="let attachment of loadedEvent.Documents" <span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial MDGPR' " style="background-color: #ffb703;">
(click)="viewDocument(attachment.DocId, attachment)"> {{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal MDGPR' " style="background-color: #f05d5e;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial PR' " style="background-color: #99e47b;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Pessoal PR' " style="background-color: #958bfc;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
</p>
</div>
<div class="content-details">
<ion-label> <ion-label>
<p class="attach-title-item d-block">{{attachment.Assunto}}</p> <p>{{customDate}}</p>
<p><span class="span-left">{{attachment.Sender}}</span><span class="span-right">{{ attachment.DocDate | date: 'dd-MM-yyyy HH:mm' }}</span></p> <p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) == toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">das {{loadedEvent.workflowInstanceDataFields.StartDate | date: 'HH:mm'}} às {{loadedEvent.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
<p *ngIf="toDateString(loadedEvent.workflowInstanceDataFields.StartDate) != toDateString(loadedEvent.workflowInstanceDataFields.EndDate)">{{loadedEvent.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ loadedEvent.workflowInstanceDataFields.StartDate | date: 'dd/M/yy'}} </p>
<p *ngIf="!loadedEvent.workflowInstanceDataFields.IsRecurring">(Não se repete)</p>
<p *ngIf="loadedEvent.workflowInstanceDataFields.IsRecurring">Repete</p>
</ion-label> </ion-label>
</ion-item> </div>
</ion-list>
</div> </div>
<div class="line"></div>
<div class="overflow-y-auto">
<div class="middle-content">
<div *ngIf="loadedEvent.workflowInstanceDataFields.ParticipantsList">
<h5>Intervenientes</h5>
<div *ngFor="let att of loadedEvent.workflowInstanceDataFields.ParticipantsList">
<ion-label>{{att.Name}}</ion-label>
</div>
<div class="line"></div>
</div>
<div *ngIf="loadedEvent.workflowInstanceDataFields.Body">
<h5>Detalhes</h5>
<ion-item lines="none" class="ion-no-margin ion-no-padding">
<p [innerHTML]="loadedEvent.workflowInstanceDataFields.Body"></p>
</ion-item>
<div class="line"></div>
</div>
</div>
<div *ngIf="loadedEvent.Documents" class="bottom-content width-100">
<ion-list>
<h5>Documentos Anexados </h5>
<ion-item class="ion-no-margin ion-no-padding cursor-pointer"
*ngFor="let attachment of loadedEvent.Documents"
(click)="viewDocument(attachment.DocId, attachment)">
<ion-label>
<p class="attach-title-item d-block">{{attachment.Assunto}}</p>
<p><span class="span-left">{{attachment.Sender}}</span><span class="span-right">{{ attachment.DocDate | date: 'dd-MM-yyyy HH:mm' }}</span></p>
</ion-label>
</ion-item>
</ion-list>
</div>
</div>
</div> </div>
</div> <div *ngIf="showAside" class="aside-right flex-column height-100 cursor-pointer">
<div class="aside-buttons">
<div *ngIf="showAside" class="aside-right flex-column height-100 cursor-pointer"> <button hidden full class="btn-ok" shape="round" >Editar evento</button>
<div class="aside-buttons"> <button (click)="approveTask(loadedEvent.serialNumber)" full class="btn-ok" shape="round" >Aprovar</button>
<button hidden full class="btn-ok" shape="round" >Editar evento</button> <button (click)="emendTask(loadedEvent.serialNumber)" class="btn-cancel" shape="round" >Rever</button>
<button (click)="approveTask(loadedEvent.serialNumber)" full class="btn-ok" shape="round" >Aprovar</button> <div class="solid"></div>
<button (click)="emendTask(loadedEvent.serialNumber)" class="btn-cancel" shape="round" >Rever</button> <button full class="btn-cancel" shape="round" (click)="editar(loadedEvent.serialNumber)" >Editar</button>
<div class="solid"></div> <button (click)="rejectTask(loadedEvent.serialNumber)" full class="btn-delete" shape="round" >Rejeitar</button>
<button full class="btn-cancel" shape="round" (click)="editar(loadedEvent.serialNumber)" >Editar</button> </div>
<button (click)="rejectTask(loadedEvent.serialNumber)" full class="btn-delete" shape="round" >Rejeitar</button>
</div> </div>
</div> </div>
</div> </div>
</ion-content> </ion-content>
+12 -55
View File
@@ -48,15 +48,21 @@
</mat-menu> </mat-menu>
</div> </div>
<div class="title"> <div class="title">
<ion-label (click)="testEditMessage(msg)">{{msg.u.name}}</ion-label> <ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{msg.duration}}</span> <span class="time">{{msg.duration}}</span>
</div> </div>
<div class="d-flex justify-space-between"> <div class="d-flex justify-space-between">
<ion-label class="flex-0">{{msg.msg}}</ion-label> <ion-label class="flex-0">{{msg.msg}} </ion-label>
<ion-label class="float-status-all float-status" > <ion-label class="float-status-all float-status" >
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon> {{ msg.messageSend }}
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon> {{ msg.received.length }}
{{ msg.viewed.length }}
<ion-icon *ngIf="msg.messageSend == false" src="assets/images/clock-regular.svg"></ion-icon>
<ion-icon *ngIf="msg.messageSend == true && msg.received.length == 0" src="assets/images/check-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.messageSend && msg.received.length >= 1 && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.viewed.length >= 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon>
</ion-label> </ion-label>
{{last ? scrollToBottom() : ''}} {{last ? scrollToBottom() : ''}}
</div> </div>
@@ -136,55 +142,6 @@
</ion-label><br /> </ion-label><br />
</div> </div>
</div> </div>
<!-- <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
<div *ngIf="msg.file">
<div *ngIf="msg.file.type == 'application/img'">
<div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
</fa-icon>
<mat-menu #beforeMenu="matMenu" xPosition="before">
<button (click)="deleteMessage(msg._id)" class="menuButton">Apagar mensagem</button>
</mat-menu>
</div>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{msg.duration}}</span>
</div>
<div>
<ion-label>{{msg.msg}}</ion-label>
<div *ngIf="msg.file" class="message-attachments">
<div>
<div (click)="openPreview(msg)">
File
<img *ngIf="msg.attachments[0].image_url" src="{{msg.attachments[0].image_url}}" alt="image">
</div>
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
</div>
</div>
</div> -->
<!-- <div *ngIf="msg.file">
<div class="info-meeting" *ngIf="msg.file.type == 'application/meeting'">
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal">
<ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label>
</button><br />
<ion-label class="info-meeting-medium">
<ion-icon name="calendar-outline"></ion-icon> De {{showDateDuration(msg.file.start_date)}} a
{{showDateDuration(msg.file.end_date)}}
</ion-label><br />
<ion-label class="info-meeting-medium">
<ion-icon></ion-icon>
<ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}
</ion-label><br />
</div>
{{last ? scrollToBottom() : ''}}
</div> -->
</div> </div>
</div> </div>
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> <ion-fab horizontal="end" vertical="bottom" slot="fixed">
@@ -196,7 +153,7 @@
</ion-content> </ion-content>
<ion-footer> <ion-footer (click)="wsChatMethodsService.getDmRoom(roomId).sendReadMessage()">
<div class="typing" *ngIf="wsChatMethodsService.getDmRoom(roomId).otherUserType == true" > <div class="typing" *ngIf="wsChatMethodsService.getDmRoom(roomId).otherUserType == true" >
<ngx-letters-avatar *ngIf="showAvatar" <ngx-letters-avatar *ngIf="showAvatar"
+4 -10
View File
@@ -19,7 +19,6 @@ import { ThemeService } from 'src/app/services/theme.service'
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page'; import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { StorageService } from 'src/app/services/storage.service'; import { StorageService } from 'src/app/services/storage.service';
import { Directory, Filesystem } from '@capacitor/filesystem';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page'; import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service' import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
@@ -335,7 +334,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.chatService.getMembers(this.roomId).subscribe(res => { this.chatService.getMembers(this.roomId).subscribe(res => {
this.members = res['members']; this.members = res['members'];
this.dmUsers = res['members'].filter(data => data.username != this.loggedUser.me.username) this.dmUsers = res['members'].filter(data => data.username != this.loggedUser.me.username)
console.log(res); console.log('this.dmUsers', res);
console.log(this.dmUsers); console.log(this.dmUsers);
this.showLoader = false; this.showLoader = false;
}); });
@@ -466,8 +465,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}, },
temporaryData: formData, temporaryData: formData,
attachments: [{ attachments: [{
"title": file.path , "title": file.path,
"image_url": 'data:image/jpeg;base64,' +file.base64String, // "image_url": "",
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
}] }]
@@ -498,7 +497,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
temporaryData: formData, temporaryData: formData,
attachments: [{ attachments: [{
"title": capturedImageTitle , "title": capturedImageTitle ,
"image_url": capturedImage, "image_url": "",
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
}] }]
@@ -775,11 +774,6 @@ console.log(msg);
} }
testEditMessage(msg:MessageService) {
msg.receptorReceive()
// alert('cool!')
}
} }
+1 -1
View File
@@ -88,7 +88,7 @@ class SessionService {
this.reset(new UserSession()) this.reset(new UserSession())
} }
private save() { save() {
localstoreService.set(this.keyName, { localstoreService.set(this.keyName, {
user: this._user user: this._user
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M232 120C232 106.7 242.7 96 256 96C269.3 96 280 106.7 280 120V243.2L365.3 300C376.3 307.4 379.3 322.3 371.1 333.3C364.6 344.3 349.7 347.3 338.7 339.1L242.7 275.1C236 271.5 232 264 232 255.1L232 120zM256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0zM48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48C141.1 48 48 141.1 48 256z"/></svg>

After

Width:  |  Height:  |  Size: 667 B