diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index b51d78918..9a57632a9 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -27,7 +27,36 @@ export class InactivityGuard implements CanActivate { if ( (this.platform.is('desktop') || this.platform.is('mobileweb')) ) { - this.FirstEnterService.enter() + if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) { + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } + } + else if(this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)){ + this.router.navigate(['/home/chat']); + } + else if(this.p.userPermission(this.p.permissionList.Actions.access)) { + this.router.navigate(['/home/publications']); + } else { + + this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Utilizador sem acesso a aplicação', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }).then( async (alertPopup) => { + await alertPopup.present(); + }) + + } return false } else if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) { @@ -48,7 +77,34 @@ export class InactivityGuard implements CanActivate { else { if((SessionStore?.user?.Inactivity)) { - this.FirstEnterService.enter() + if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } + } + else if(this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)){ + this.router.navigate(['/home/chat']); + } + else if(this.p.userPermission(this.p.permissionList.Actions.access)){ + this.router.navigate(['/home/publications']); + } else { + this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Utilizador sem acesso a aplicação', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }).then( async (alertPopup)=>{ + await alertPopup.present(); + }) + } return false } diff --git a/src/app/models/chatMethod.ts b/src/app/models/chatMethod.ts index b6186d644..73570fa16 100644 --- a/src/app/models/chatMethod.ts +++ b/src/app/models/chatMethod.ts @@ -71,6 +71,7 @@ export interface Message { rid: string; msg: string; ts: Ts; + sendAttempt?: number u: U; from: 'Offline'|'History'|'stream'| 'send' t: string; diff --git a/src/app/pages/chat/group-messages/group-messages.page.html b/src/app/pages/chat/group-messages/group-messages.page.html index 71a52a718..dc8a49e1f 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.html +++ b/src/app/pages/chat/group-messages/group-messages.page.html @@ -67,7 +67,7 @@ -
Tentar
+
Tentar
{{last ? scrollToBottom() : ''}} @@ -106,7 +106,7 @@ -
Tentar
+
Tentar
@@ -160,7 +160,7 @@ -
Tentar
+
Tentar
diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index ea77dd2d7..427b039c6 100644 --- a/src/app/pages/chat/messages/messages.page.html +++ b/src/app/pages/chat/messages/messages.page.html @@ -64,7 +64,7 @@ -
Tentar
+
Tentar
{{last ? scrollToBottom() : ''}} @@ -101,7 +101,7 @@ -
Tentar
+
Tentar
@@ -167,7 +167,7 @@ -
Tentar
+
Tentar
diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index 113534216..7adf49421 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -152,7 +152,9 @@ export class EventsPage implements OnInit { console.error(error) }) this.listToPresent = onwEvent; - this.totalEvent = onwEvent.length; + if(onwEvent?.length) { + this.totalEvent = onwEvent.length; + } this.showLoader = false; this.showAgendaLoader = false; } else { diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index f0a349109..8dfcd4bd5 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -198,7 +198,22 @@ export class LoginPage implements OnInit { if(pathName) { this.router.navigate([pathName]); } else { - this.FirstEnterService.enter() + if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } + } + //If user has access permission to both Chat and Action, goes to Chat by default. + else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){ + this.router.navigate(['/home/chat']); + } + else if(this.p.userPermission(this.p.permissionList.Actions.access)){ + this.router.navigate(['/home/publications']); + } } } diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 30d87b280..27d0f9372 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -71,7 +71,7 @@ export class MessageService { private ChatSystemService: ChatSystemService) { } - setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference , viewed = [], received = [], delate = false, delateRequest =false, from }:Message) { + setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference , viewed = [], received = [], delate = false, delateRequest =false, from, sendAttempt = 0 }:Message) { this.channels = channels || [] this.mentions = mentions || [] @@ -88,6 +88,7 @@ export class MessageService { this.id = id this.delate = delate this.delateRequest = delateRequest + this.sendAttempt = 0 if(this.attachments?.length >= 1 && attachments?.length >= 1) { this.attachments[0] = Object.assign(this.attachments[0], attachments[0]) @@ -149,6 +150,7 @@ export class MessageService { async send(): Promise { this.sendAttempt++; + this.manualRetry = false if(!this.hasFile) { @@ -220,7 +222,6 @@ export class MessageService { functionTimer = null; async sendRequest(params) { - if(params?.attachments) { if(params?.attachments[0]?.image_url) { delete params?.attachments[0]?.image_url @@ -229,19 +230,39 @@ export class MessageService { if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) { // console.log('online send') - this.RochetChatConnectorService.send(params).then( - (ChatMessage: any) => { - ChatMessage = ChatMessage.message.result - clearTimeout(this.functionTimer); - this.messageSend = true - this.redefinedMessage(ChatMessage) - + if(this.msg == '') { + if(this.sendAttempt >= 4) { + this.RochetChatConnectorService.send(params).then( + (ChatMessage: any) => { + ChatMessage = ChatMessage.message.result + clearTimeout(this.functionTimer); + + this.messageSend = true + this.redefinedMessage(ChatMessage) + + } + ).catch((error) => { + clearTimeout(this.functionTimer); + console.error(error) + }) } - ).catch((error) => { - clearTimeout(this.functionTimer); - console.error(error) - }) + + } else { + this.RochetChatConnectorService.send(params).then( + (ChatMessage: any) => { + ChatMessage = ChatMessage.message.result + clearTimeout(this.functionTimer); + + this.messageSend = true + this.redefinedMessage(ChatMessage) + + } + ).catch((error) => { + clearTimeout(this.functionTimer); + console.error(error) + }) + } this.functionTimer = setTimeout(() => { @@ -264,7 +285,7 @@ export class MessageService { this.RochetChatConnectorService.wsSend({message:{msg:"pong"}, loginRequired: false}) - }, 8000) + }, 3000) } else { this.RochetChatConnectorService.registerCallback({ @@ -286,6 +307,8 @@ export class MessageService { const message = this.getChatObj() + this.manualRetry = false + ChatMessage = Object.assign(message, ChatMessage) this.setData(ChatMessage) diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 25ac6a487..6c21a23f3 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -63,7 +63,7 @@ -
Tentar
+
Tentar
{{last ? scrollToBottom() : ''}} @@ -109,7 +109,7 @@ -
Tentar
+
Tentar
@@ -164,7 +164,7 @@ -
Tentar
+
Tentar
diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 3392a0e4e..07894481c 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -64,7 +64,7 @@ -
Tentar
+
Tentar
{{last ? scrollToBottom() : ''}} @@ -108,7 +108,7 @@ -
Tentar
+
Tentar
@@ -174,7 +174,7 @@ -
Tentar
+
Tentar
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index ba56d63fc..5ed180377 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -18,7 +18,7 @@ export const environment = { production: true, domain: 'gabinetedigital.local', defaultuser: 'eqformacao@oapr.gov.ao',//paulo.pinto@gabinetedigital.local - defaultuserpwd: 'M@p2022', //tabteste@006, + defaultuserpwd: 'tabteste@006', //tabteste@006, chatOffline: true, presidencia: false, version: versionData,