Bug solved on despacho pr

This commit is contained in:
Eudes Inácio
2023-02-03 14:40:09 +01:00
parent 9c76f87944
commit 715e1cff3e
11 changed files with 81 additions and 50 deletions
+9 -2
View File
@@ -43,7 +43,7 @@ export class ProfilePage implements OnInit {
private storageservice: StorageService,
private zone: NgZone,
private platform: Platform,
private eventtrigger: EventTrigger,
private eventTriger: EventTrigger,
public ThemeService: ThemeService,
) {
@@ -53,6 +53,13 @@ export class ProfilePage implements OnInit {
this.logoutOut = true
});
this.eventTriger.getObservable().subscribe((event) => {
if(event.notification == "recive") {
this.getNotificationData();
}
console.log(event)
});
setTimeout(() => {
this.hideImage = true
}, 2000)
@@ -193,7 +200,7 @@ export class ProfilePage implements OnInit {
// this.notificationservice.tempClearArray();
this.deleteNotification(index);
this.eventtrigger.publishSomeData({
this.eventTriger.publishSomeData({
notification: "deleted"
})
+1
View File
@@ -13,6 +13,7 @@ export interface Environment {
version: version;
sentryUrl: string;
despachoLabel: string
despachoLabel2: string,
}
@@ -6,8 +6,8 @@
<div class="main-header">
<app-btn-modal-dismiss (click)="goBack()" ></app-btn-modal-dismiss>
<div class="thetitle">
<ion-label *ngIf="loggeduser.Profile =='MDGPR'" >Despachos Presidenciais</ion-label>
<ion-label *ngIf="loggeduser.Profile =='PR'" >Despachos</ion-label>
<ion-label *ngIf="sessionProfile =='MDGPR'" >{{ environment.despachoLabel2 }}</ion-label>
<ion-label *ngIf="sessionProfile =='PR'" >Despachos</ion-label>
</div>
<div class="theicon btn-refresh">
<button class="btn-no-color" (click)="doRefresh($event)">
@@ -20,6 +20,7 @@ import { SortService } from 'src/app/services/functions/sort.service';
import { ThemeService } from 'src/app/services/theme.service'
import { SessionStore } from 'src/app/store/session.service';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
import { environment } from 'src/environments/environment';
@Component({
selector: 'app-despachos-pr',
@@ -50,11 +51,13 @@ export class DespachosPrPage implements OnInit {
inicial = false
loggeduser: LoginUserRespose;
sessionProfile = SessionStore.user.Profile
skeletonLoader = true
despachoprstore = DespachosprStore
listToPresent = [];
customTaskPipe = new CustomTaskPipe()
environment = environment
constructor(
private processes: ProcessesService,
+2 -1
View File
@@ -369,7 +369,8 @@ export class MessageService {
if(!roomObject.isGroup) {
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.username,ChatMessage.msg,this.rid)
console.log(ChatMessage)
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg,this.rid)
}
+53 -38
View File
@@ -12,7 +12,6 @@ import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service';
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
import { notificationObject } from '../models/notifications';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
providedIn: 'root'
@@ -39,45 +38,44 @@ export class NotificationsService {
private platform: Platform,
private router: Router,
private zone: NgZone,
private eventtrigger: EventTrigger,) {}
registerCallback({type, funx, id = uuidv4()} : {
type: notificationObject,
funx: Function
id?: string
}) {
this.callbacks[id] = { funx, id, type}
return id;
}
deleteCallback(id) {
delete this.callbacks[id]
}
private async runNotificationCallback(notification) {
for (const [key, value] of Object.entries(this.callbacks)) {
if(value.type == notification.data.Object) {
const dontRepeat = await value.funx(notification)
if(dontRepeat) {
delete this.callbacks[key]
}
} else if (value.type == '*') {
const dontRepeat = await value.funx(notification)
if(dontRepeat) {
delete this.callbacks[key]
}
}
}
private eventtrigger: EventTrigger,) {
}
// registerCallback({type, funx, id = uuidv4()} : {
// type: notificationObject,
// funx: Function
// id?: string
// }) {
// this.callbacks[id] = { funx, id, type}
// return id;
// }
// private async runNotificationCallback(notification) {
// for (const [key, value] of Object.entries(this.callbacks)) {
// if(value.type == notification.data.Object) {
// const dontRepeat = await value.funx(notification)
// if(dontRepeat) {
// delete this.callbacks[key]
// }
// } else if (value.type == '*') {
// const dontRepeat = await value.funx(notification)
// if(dontRepeat) {
// delete this.callbacks[key]
// }
// }
// }
// }
getTokenByUserIdAndId(user, userID) {
// const geturl = environment.apiURL + 'notifications/user/' + userID;
@@ -176,7 +174,7 @@ export class NotificationsService {
}
ChatSendMessageNotification(userID,title,bodymsg,roomId) {
const geturl = environment.apiURL + `notifications/send`;
const geturl = environment.apiURL + `notifications/sendbyUsername`;
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const message = {
@@ -185,6 +183,23 @@ export class NotificationsService {
}
let id = 437
console.log(userID,title,bodymsg,roomId)
this.http.post<Tokenn>(geturl+`?username=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
this.active = true
console.log(data)
}, (error) => {
console.log(error)
})
}
ChatSendMessageNotificationGrup(userID,title,bodymsg,roomId) {
const geturl = environment.apiURL + `notifications/send`;
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const message = {
"Service": "chat",
"IdObject": roomId
}
console.log(userID,title,bodymsg,roomId)
this.http.post<Tokenn>(geturl+`?userId=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
this.active = true
console.log(data)