fix chat un read messges

This commit is contained in:
Peter Maquiran
2024-03-01 14:42:16 +01:00
parent 1f4274e3e0
commit 9c7c1589e6
10 changed files with 104 additions and 24 deletions
+1 -1
View File
@@ -211,4 +211,4 @@
"styleext": "scss" "styleext": "scss"
} }
} }
} }
@@ -21,7 +21,7 @@
</div> </div>
<div> <div>
<div class="subject" [ngClass]="{'add-ellipsis': i != selectedIndex}">{{ attachment.Assunto || "Sem assunto" }}</div> <div class="subject add-ellipsis">{{ attachment.Assunto || "Sem assunto" }}</div>
<div class="user" > <div class="user" >
{{ attachment.Sender }} {{ attachment.Sender }}
</div> </div>
@@ -25,7 +25,7 @@
margin: 0px; margin: 0px;
} }
.subject { .subject {
max-width: 230px; max-width: 150px;
} }
ion-icon { ion-icon {
@@ -47,7 +47,7 @@ iframe {
} }
.subject { .subject {
max-width: 300px !important; max-width: 200px !important;
} }
} }
+31 -9
View File
@@ -82,6 +82,28 @@ export class ChatService {
return this.http.get(environment.apiChatUrl + 'rooms.info', opts); return this.http.get(environment.apiChatUrl + 'rooms.info', opts);
} }
GetSubscriptionRoomUnreadM(roomId) {
let params = new HttpParams();
params = params.set("roomId", roomId);
let opts = {
headers: this.headers,
params: params
}
return this.http.get(environment.apiChatUrl + 'subscriptions.getOne', opts);
}
getChannelInfo(roomId: any) {
let params = new HttpParams();
params = params.set("roomId", roomId);
params = params.set("unread", "true");
let opts = {
headers: this.headers,
params: params
}
return this.http.get(environment.apiChatUrl + 'rooms.info', opts);
}
customsRooms(params: any) { customsRooms(params: any) {
let opts = { let opts = {
headers: this.headers, headers: this.headers,
@@ -348,12 +370,12 @@ export class ChatService {
setheader() { setheader() {
try { try {
if (this.p.userPermission(this.p.permissionList.Chat.access) && SessionStore.user.ChatData) { if (this.p.userPermission(this.p.permissionList.Chat.access) && SessionStore.user.ChatData) {
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)) {
// //
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId); this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken); this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
this.options = { this.options = {
@@ -375,10 +397,10 @@ export class ChatService {
let options = { let options = {
headers: this.headers headers: this.headers
}; };
try { try {
let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise(); let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise();
let data = { let data = {
status: res['status'], status: res['status'],
data: { data: {
@@ -412,7 +434,7 @@ export class ChatService {
await this.refreshtoken(); await this.refreshtoken();
}, 60000) }, 60000)
} }
} }
@@ -436,13 +458,13 @@ export class ChatService {
if(this.timerEventTriggerDateLastUpdate == null) { if(this.timerEventTriggerDateLastUpdate == null) {
return true return true
} }
if(diffTime >= 5000) { if(diffTime >= 5000) {
return true return true
} }
return false return false
} }
functionTimer = null; functionTimer = null;
@@ -460,7 +482,7 @@ export class ChatService {
} else { } else {
this.resetTimer() this.resetTimer()
} }
}, 60000 * 15); // time is in milliseconds }, 60000 * 15); // time is in milliseconds
} }
+5 -1
View File
@@ -370,7 +370,9 @@ export class ChatSystemService {
this.RochetChatConnectorService.streamNotifyLogged().then((subscription => { })) this.RochetChatConnectorService.streamNotifyLogged().then((subscription => { }))
this.RochetChatConnectorService.subStreamMessageUser().then((subscription => { })) this.RochetChatConnectorService.subStreamMessageUser().then((subscription => {
console.log({subscription})
}))
} else { } else {
setTimeout(() => { setTimeout(() => {
@@ -490,6 +492,8 @@ export class ChatSystemService {
room.sortRoomList = this.sortRoomList room.sortRoomList = this.sortRoomList
room.chatServiceDeleteRoom = this.deleteRoom room.chatServiceDeleteRoom = this.deleteRoom
room.isGroup = !this.isIndividual(roomData) room.isGroup = !this.isIndividual(roomData)
room.info()
// create individual room // create individual room
if (this.isIndividual(roomData)) { if (this.isIndividual(roomData)) {
@@ -461,6 +461,11 @@ export class RochetChatConnectorService {
resolve(message) resolve(message)
return true return true
} }
if (message.id == requestId || message?.subs?.[0] == requestId) { // same request send
resolve(message)
return true
}
} }
}) })
}); });
@@ -588,6 +593,40 @@ export class RochetChatConnectorService {
}); });
} }
loadHistoryUnread(roomId, limit: number = 50) {
const requestId = uuidv4()
const message = {
msg: "method",
method: "loadHistory",
id: requestId,
params: [
roomId,
null,
limit,
{
"$date": 1480377601
}
]
}
this.ws.send({ message, requestId: 'loadHistory' })
return new Promise<chatHistory>((resolve, reject) => {
this.ws.registerCallback({
type: 'Onmessage', funx: (message) => {
//
if (message.id == requestId) { // same request send
resolve(message)
return true
}
}
})
});
}
setStatus(status: 'online' | 'busy' | 'away' | 'offline') { setStatus(status: 'online' | 'busy' | 'away' | 'offline') {
const requestId = uuidv4() const requestId = uuidv4()
+16 -1
View File
@@ -379,6 +379,17 @@ export class RoomService {
}, 5) }, 5)
}) })
async info() {
// set unread messages
const response: any = await this.chatService.GetSubscriptionRoomUnreadM(this.id).toPromise()
if(response?.subscription?.unread >= 1) {
this.messageUnread = true
}
}
getUsersByStatus(status: 'offline' | 'online') { getUsersByStatus(status: 'offline' | 'online') {
return this.getAllUsers().filter((user => { return this.getAllUsers().filter((user => {
@@ -958,6 +969,10 @@ export class RoomService {
const users = this.getUsersByStatus('online') const users = this.getUsersByStatus('online')
if(chatHistory.result.unreadNotLoaded >= 1) {
this.messageUnread = true
}
for (let message of chatHistory.result.messages.reverse()) { for (let message of chatHistory.result.messages.reverse()) {
message.origin = 'history' message.origin = 'history'
@@ -1231,7 +1246,7 @@ export class RoomService {
setTimeout(() => { setTimeout(() => {
console.log("getGroupMembers", this.membersExcludeMe) // console.log("getGroupMembers", this.membersExcludeMe)
}, 500) }, 500)
} }
@@ -1,5 +1,5 @@
<ion-header *ngIf="task" class="ion-no-border "> <ion-header *ngIf="task" class="ion-no-border ">
<div class="main-header mt-30 px-20"> <div *ngIf="dropButton" class="main-header mt-30 px-20">
<div class="title-content width-100 d-flex justify-space-between align-center"> <div class="title-content width-100 d-flex justify-space-between align-center">
<div class=" btn-dismiss font-30-rem cursor-pointer" (click)="goBack.emit()" defaultHref="#"> <div class=" btn-dismiss font-30-rem cursor-pointer" (click)="goBack.emit()" defaultHref="#">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src='assets/images/icons-arrow-arrow-left.svg'></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src='assets/images/icons-arrow-arrow-left.svg'></ion-icon>
@@ -28,7 +28,7 @@
</div> </div>
<div class=" flex-1 d-flex flex-column height-100 d-flex overflow-y-auto-desktop" > <div class=" flex-1 d-flex flex-column height-100 d-flex overflow-y-auto-desktop" >
<div class="upper-content" > <div *ngIf="dropButton" class="upper-content" >
<div class="content-details"> <div class="content-details">
<div class="mobile-header"> <div class="mobile-header">
<ion-label> <ion-label>
@@ -44,7 +44,7 @@
</ion-label> </ion-label>
</div> </div>
</div> </div>
<div class="line mx-20"></div> <div *ngIf="dropButton" class="line mx-20"></div>
<div style=" <div style="
display: flex; display: flex;
+3 -3
View File
@@ -1,7 +1,7 @@
import { Environment } from './../app/models/envarioment' import { Environment } from './../app/models/envarioment'
import { oaprProd } from './suport/oapr' import { oaprProd } from './suport/oapr'
import { doneITProd } from './suport/doneIt' // import { doneITProd } from './suport/doneIt'
// import { DevDev } from './suport/dev' import { DevDev } from './suport/dev'
export const environment: Environment = doneITProd; export const environment: Environment = DevDev;
+3 -3
View File
@@ -1,7 +1,7 @@
import { Environment } from './../app/models/envarioment' import { Environment } from './../app/models/envarioment'
import { oaprDev } from './suport/oapr' import { oaprDev } from './suport/oapr'
import { doneITDev } from './suport/doneIt' // import { doneITDev } from './suport/doneIt'
//import { DevDev } from './suport/dev' import { DevDev } from './suport/dev'
export const environment: Environment = doneITDev export const environment: Environment = DevDev