mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
Merge branch 'feature/viewer-attachment' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into feature/viewer-attachment
This commit is contained in:
@@ -32,6 +32,8 @@ import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
@@ -128,6 +130,7 @@ export class ChatPage implements OnInit {
|
||||
private RochetChatConnectorService: RochetChatConnectorService,
|
||||
private zone: NgZone,
|
||||
public RouteService: RouteService,
|
||||
private ChangeDetectorRef: ChangeDetectorRef
|
||||
) {
|
||||
|
||||
this.headers = new HttpHeaders();;
|
||||
@@ -175,8 +178,18 @@ export class ChatPage implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
this.ChatSystemService.setMainChangeDetector(()=> {
|
||||
this.changeDetector()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
changeDetector = () => {
|
||||
console.log('run detection')
|
||||
this.ChangeDetectorRef.detectChanges()
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy() {
|
||||
// this.setStatus('offline');
|
||||
this.routerSubscription?.unsubscribe();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ion-header class="ion-no-border">
|
||||
<ion-toolbar class="header-toolbar">
|
||||
<div class="main-header">
|
||||
<div class="main-header" *ngIf="ChatSystemService.getGroupRoom(roomId)">
|
||||
<div class="header-top">
|
||||
<!-- <app-btn-modal-dismiss></app-btn-modal-dismiss> -->
|
||||
<div class="left">
|
||||
@@ -45,7 +45,7 @@
|
||||
</ion-header>
|
||||
|
||||
|
||||
<ion-content>
|
||||
<ion-content *ngIf="ChatSystemService.getGroupRoom(roomId)">
|
||||
|
||||
<div (click)="handleClick()" class="messages overflow-y-auto" #scrollMe>
|
||||
<div class="welcome-text">
|
||||
@@ -277,7 +277,7 @@
|
||||
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-footer *ngIf="ChatSystemService.getGroupRoom(roomId)">
|
||||
|
||||
<div class="typing" *ngIf="ChatSystemService.getGroupRoom(roomId).otherUserType == true">
|
||||
<ngx-letters-avatar *ngIf="showAvatar" [avatarName]="ChatSystemService.getGroupRoom(roomId).name" [width]="30"
|
||||
|
||||
@@ -35,7 +35,6 @@ import { RouteService } from 'src/app/services/route.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { sanitize } from "sanitize-filename-ts";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
templateUrl: './group-messages.page.html',
|
||||
@@ -108,7 +107,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private file: File,
|
||||
private fileOpener: FileOpener,
|
||||
public RouteService: RouteService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
private FileValidatorService: FileValidatorService,
|
||||
private ChangeDetectorRef: ChangeDetectorRef
|
||||
) {
|
||||
this.ChatSystemService.getUser()
|
||||
|
||||
@@ -137,6 +137,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
open() {
|
||||
try {
|
||||
this.ChatSystemService.getGroupRoom(this.roomId).loadHistory({});
|
||||
@@ -144,6 +146,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.ChatSystemService.openRoom(this.roomId)
|
||||
this.groupNameFormart = this.ChatSystemService.getGroupRoom(this.roomId).name.split('-').join(' ')
|
||||
|
||||
this.ChatSystemService.getGroupRoom(this.roomId).setChangeDetector(()=> {
|
||||
this.changeDetector()
|
||||
})
|
||||
} catch (error) {
|
||||
setTimeout(() => {
|
||||
this.open()
|
||||
@@ -151,6 +156,12 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeDetector = () => {
|
||||
console.log('run detection page')
|
||||
this.ChangeDetectorRef.detectChanges()
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.loggedUser = this.loggedUserChat;
|
||||
|
||||
@@ -35,6 +35,7 @@ import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { sanitize } from "sanitize-filename-ts";
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
|
||||
|
||||
@@ -121,7 +122,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private fileOpener: FileOpener,
|
||||
private router: Router,
|
||||
public RochetChatConnectorService: RochetChatConnectorService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
private FileValidatorService: FileValidatorService,
|
||||
private ChangeDetectorRef: ChangeDetectorRef
|
||||
) {
|
||||
|
||||
try {
|
||||
@@ -140,6 +142,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.ChatSystemService.getDmRoom(this.roomId).loadHistory({})
|
||||
this.ChatSystemService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.ChatSystemService.openRoom(this.roomId)
|
||||
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(()=> {
|
||||
|
||||
this.changeDetector()
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
@@ -147,8 +153,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
} catch (error) {
|
||||
//alert(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeDetector = () => {
|
||||
console.log('run detection page')
|
||||
this.ChangeDetectorRef.detectChanges()
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
templateUrl: './group-messages.page.html',
|
||||
@@ -103,7 +103,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
private platform: Platform,
|
||||
private fileOpener: FileOpener,
|
||||
public p: PermissionService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
private FileValidatorService: FileValidatorService,
|
||||
private ChangeDetectorRef: ChangeDetectorRef
|
||||
) {
|
||||
|
||||
this.ChatSystemService.getUser()
|
||||
@@ -119,7 +120,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
this.ChatSystemService.openRoom(this.roomId)
|
||||
this.ChatSystemService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.groupNameFormart = this.ChatSystemService.getGroupRoom(this.roomId).name.split('-').join(' ')
|
||||
|
||||
this.ChatSystemService.getGroupRoom(this.roomId).setChangeDetector(()=> {
|
||||
this.changeDetector()
|
||||
})
|
||||
this.showAvatar = false
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -131,6 +134,12 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
|
||||
}
|
||||
|
||||
changeDetector = () => {
|
||||
console.log('run detection shared')
|
||||
this.ChangeDetectorRef.detectChanges()
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.loggedUser = this.loggedUserChat;
|
||||
//setTimeout(() => {
|
||||
|
||||
@@ -34,6 +34,7 @@ import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
import { ChatMessageDebuggingPage } from 'src/app/shared/popover/chat-message-debugging/chat-message-debugging.page';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
@@ -123,7 +124,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private platform: Platform,
|
||||
private fileOpener: FileOpener,
|
||||
public p: PermissionService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
private FileValidatorService: FileValidatorService,
|
||||
private ChangeDetectorRef: ChangeDetectorRef
|
||||
) {
|
||||
// update
|
||||
this.checkAudioPermission()
|
||||
@@ -138,6 +140,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
this.ChatSystemService.openRoom(this.roomId)
|
||||
|
||||
this.ChatSystemService.getDmRoom(this.roomId)
|
||||
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(()=> {
|
||||
this.changeDetector()
|
||||
})
|
||||
|
||||
this.showAvatar = false
|
||||
|
||||
|
||||
@@ -154,6 +161,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
|
||||
changeDetector = () => {
|
||||
console.log('run detection shared')
|
||||
this.ChangeDetectorRef.detectChanges()
|
||||
}
|
||||
|
||||
|
||||
async ChatMessageDebuggingPage() {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
|
||||
@@ -114,6 +114,74 @@ export class NotificationHolderService {
|
||||
}
|
||||
|
||||
|
||||
stractureNotificationObject(notification) {
|
||||
const element = notification
|
||||
let notificationObject;
|
||||
|
||||
if (element.notification) {
|
||||
|
||||
notificationObject = {
|
||||
id: notification?.id || uuidv4(),
|
||||
title: element.notification.title,
|
||||
Service: element.data.Service,
|
||||
Object: element.data.Object,
|
||||
IdObject: element.data.IdObject,
|
||||
FolderId: element.data.FolderId,
|
||||
body: element.notification.body,
|
||||
dateInit: this.getFormatedTime(element.data.dateInit),
|
||||
dateEnd: this.getFormatedTime(element.data.dateEnd),
|
||||
Location: element.data.Location,
|
||||
TypeAgenda: element.data.TypeAgenda,
|
||||
Role: element.data.Role,
|
||||
Status: element.data.Status,
|
||||
read: false,
|
||||
}
|
||||
|
||||
} else if (element.data) {
|
||||
notificationObject = {
|
||||
id: notification?.id || uuidv4(),
|
||||
title: element.title,
|
||||
Service: element.data.Service,
|
||||
Object: element.data.Object,
|
||||
IdObject: element.data.IdObject,
|
||||
FolderId: element.data.FolderId,
|
||||
body: element.body,
|
||||
dateInit: this.getFormatedTime(element.data.dateInit),
|
||||
dateEnd: this.getFormatedTime(element.data.dateEnd),
|
||||
Location: element.data.Location,
|
||||
TypeAgenda: element.data.TypeAgenda,
|
||||
Role: element.data.Role,
|
||||
Status: element.data.Status,
|
||||
read: false,
|
||||
}
|
||||
|
||||
} else {
|
||||
{
|
||||
notificationObject = {
|
||||
id: notification?.id || uuidv4(),
|
||||
FolderId: element.FolderId,
|
||||
IdObject: element.IdObject,
|
||||
Location: element.Location,
|
||||
Object: element.Object,
|
||||
Role: element.Role,
|
||||
Service: element.Service,
|
||||
Status: element.Status,
|
||||
TypeAgenda: element.TypeAgenda,
|
||||
body: element.body,
|
||||
dateEnd: element.dateEnd,
|
||||
dateInit: element.dateInit,
|
||||
index: element.index,
|
||||
title: element.title,
|
||||
read: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notificationObject.hashCode = (SHA1(notification)).toString()
|
||||
|
||||
return notificationObject
|
||||
}
|
||||
|
||||
|
||||
addNotification(notification) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user