Merge branch 'feature/viewer-attachment' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into feature/viewer-attachment

This commit is contained in:
Eudes Inácio
2024-03-11 10:24:48 +01:00
10 changed files with 169 additions and 18 deletions
+9 -2
View File
@@ -48,6 +48,7 @@ export class ChatSystemService {
loadingUsers = false
onRoomsLoad = new Subscribe({ execute: false, deleteOnExecute: true })
private mainChangeDetector: Function = () => {}
constructor(
@@ -66,7 +67,7 @@ export class ChatSystemService {
private AttachmentsService: AttachmentsService,
private NetworkServiceService: NetworkServiceService,
private ViewedMessageService: ViewedMessageService,
private notificationService: NotificationsService
private notificationService: NotificationsService,
) {
@@ -148,9 +149,15 @@ export class ChatSystemService {
});
}
} catch(error) {}
}
setMainChangeDetector(x:Function) {
this.mainChangeDetector = x
}
runMainChangeDetector() {
console.log("change")
this.mainChangeDetector()
}
loadChat() {
+8 -2
View File
@@ -25,6 +25,7 @@ import { ChatSystemService } from './chat-system.service';
import { ViewedMessageService } from './viewed-message.service'
import * as FIFOProcessQueue from 'fifo-process-queue';
import { NotificationsService } from '../notifications.service';
import { ChangeDetectorRef } from '@angular/core';
@Injectable({
providedIn: 'root'
@@ -84,6 +85,7 @@ export class RoomService {
sortRoomList = () => { }
chatServiceDeleteRoom = (roomId) => { }
private changeDetector: Function = () => {}
constructor(
public RochetChatConnectorService: RochetChatConnectorService,
@@ -190,6 +192,11 @@ export class RoomService {
}
setChangeDetector(x:Function) {
console.log("set change detector")
this.changeDetector = x
}
get online() {
if (!this.isGroup) {
@@ -372,8 +379,6 @@ export class RoomService {
}
this.messageUnread = true
// this.sortRoomList()
setTimeout(() => {
this.scrollDown()
}, 50)
@@ -386,6 +391,7 @@ export class RoomService {
this.name = ChatMessage.msg
}
this.changeDetector()
setTimeout(() => {
done()
}, 5)
+18 -3
View File
@@ -14,9 +14,10 @@ import { notificationObject } from '../models/notifications';
import { Capacitor } from '@capacitor/core';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
import { ChatService } from 'src/app/services/chat.service';
import { FCM } from '@capacitor-community/fcm';
import { ChatSystemService } from './chat/chat-system.service';
import {ChatController} from 'src/app/controller/chat'
@Injectable({
providedIn: 'root'
@@ -42,6 +43,8 @@ export class NotificationsService {
notificationReceived: EventEmitter<void> = new EventEmitter<void>();
token = ''
ChatController = ChatController
constructor(
private http: HttpClient,
private storageService: StorageService,
@@ -82,7 +85,7 @@ export class NotificationsService {
}) .catch((error) => {
console.log("Register device error", error)
})
} catch (error) {
console.log("Granted permission error", error)
}
@@ -199,6 +202,7 @@ export class NotificationsService {
this.active = true
console.log('NOtification Listener', notification)
this.storenotification(notification)
this.chatNotification(notification)
}
@@ -206,11 +210,13 @@ export class NotificationsService {
} else {
this.afMessaging.messages.subscribe((notification) => {
console.log(notification)
this.storenotification(notification)
this.notificationReceived.emit();
this.eventtrigger.publishSomeData({
notification: "recive"
})
this.chatNotification(notification)
// Handle the received message, e.g., show a notification
});
}
@@ -393,4 +399,13 @@ export class NotificationsService {
// })()
}
chatNotification(_notification) {
const notification = this.NotificationHolderService.stractureNotificationObject(_notification)
if (notification?.notification?.data?.Service === "chat" || notification?.Service === "chat") {
this.ChatController.ChatSystemService.runMainChangeDetector()
}
}
}