- {{msg.u.name}}
+ {{msg.u.name}}
{{msg.duration}}
diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts
index bc63ba7b4..ad78dcbe1 100644
--- a/src/app/pages/chat/messages/messages.page.ts
+++ b/src/app/pages/chat/messages/messages.page.ts
@@ -856,6 +856,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
// dialogTitle: 'Share with buddies',
// });
// }
+
+
+ hkellor() {
+ // alert('cool!')
+ }
+
}
diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts
index 9f2092bdd..bf96fd57c 100644
--- a/src/app/pages/login/login.page.ts
+++ b/src/app/pages/login/login.page.ts
@@ -102,8 +102,8 @@ export class LoginPage implements OnInit {
if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
- await this.authService.loginChat();
- await this.authService.loginToChatWs()
+ // await this.authService.loginChat();
+ // await this.authService.loginToChatWs()
this.getToken();
SessionStore.setInativity(true);
@@ -117,8 +117,8 @@ export class LoginPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run()
- await this.authService.loginChat();
- await this.authService.loginToChatWs()
+ // await this.authService.loginChat();
+ // await this.authService.loginToChatWs()
this.getToken();
this.router.navigateByUrl('/pin', { replaceUrl: true });
}
diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts
index 1cc20f8e8..77f1df29a 100644
--- a/src/app/pages/publications/publications.page.ts
+++ b/src/app/pages/publications/publications.page.ts
@@ -11,8 +11,6 @@ import { Publication } from 'src/app/models/publication';
import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page';
import { EditActionPage } from './edit-action/edit-action.page';
import { ToastService } from 'src/app/services/toast.service';
-import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
-import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ThemeService } from 'src/app/services/theme.service'
@@ -39,8 +37,6 @@ export class PublicationsPage implements OnInit {
months: string[];
days: string[];
- publicationEventFolderStorage = PublicationEventFolderStorage
- publicationTravelFolderService = PublicationTravelFolderStore
desktopComponent: any = {
showViewPublication: false,
diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts
index 949d3a0b7..5d2a2aba2 100644
--- a/src/app/pages/publications/view-publications/view-publications.page.ts
+++ b/src/app/pages/publications/view-publications/view-publications.page.ts
@@ -5,9 +5,6 @@ import { Publication } from 'src/app/models/publication';
import { PublicationFolder } from 'src/app/models/publicationfolder';
import { PublicationPipe } from 'src/app/pipes/publication.pipe';
import { PublicationsService } from 'src/app/services/publications.service';
-import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
-import { PublicationListStorage } from 'src/app/store/publication-list.service';
-import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
import { NewPublicationPage } from '../new-publication/new-publication.page';
import { PublicationDetailPage } from './publication-detail/publication-detail.page';
import { SqliteService } from 'src/app/services/sqlite.service';
@@ -31,11 +28,6 @@ export class ViewPublicationsPage implements OnInit {
id: string;
error: any;
- publicationListStorage = PublicationListStorage
- //
- publicationEventFolderStorage = PublicationEventFolderStorage
- publicationTravelFolderService = PublicationTravelFolderStore
-
publicationPipe = new PublicationPipe()
publicationDitails: any;
getpublication = [];
@@ -169,7 +161,6 @@ export class ViewPublicationsPage implements OnInit {
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
console.log('PUBLICATIONS IMAGEs',this.publicationList)
- this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList;
this.showLoader = false;
@@ -207,7 +198,6 @@ export class ViewPublicationsPage implements OnInit {
});
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
- this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList;
this.showLoader = false;
@@ -219,7 +209,6 @@ export class ViewPublicationsPage implements OnInit {
if (error.status == '404') {
this.error = 'Sem publicações disponíveis!';
this.publicationList = [];
- this.publicationListStorage.add(folderId, this.publicationList)
}
this.showLoader = false;
});
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index 25bd05169..c4b9b6bf1 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -165,7 +165,6 @@ export class AuthService {
try {
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
message.file.guid = guid.path
- alert('uploaded')
await this.storage.set(guid.path, message.file.image_url).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
@@ -236,7 +235,7 @@ export class AuthService {
}, 1)
}
- autologout(expirationDate:number){
+ autologout(expirationDate:number) {
setTimeout(()=>{
this.logout();
}, expirationDate)
@@ -256,13 +255,13 @@ export class AuthService {
}
//Get user data from RocketChat | global object
- getUserData(){
+ getUserData() {
this.storageService.get(AuthConnstants.AUTH).then(res=>{
this.userData$.next(res);
});
}
- logoutChat(){
+ logoutChat() {
//this.storageService.clear();
/* this.storageService.removeStorageItem(AuthConnstants.AUTH).then(res =>{
this.userData$.next('');
diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts
index 78a481246..92c5e5c4c 100644
--- a/src/app/services/chat.service.ts
+++ b/src/app/services/chat.service.ts
@@ -32,13 +32,13 @@ export class ChatService {
private storageService:StorageService,
)
{
- this.loggedUserChat = authService.ValidatedUserChat;
- this.headers = new HttpHeaders();
- this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId);
- this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
- this.options = {
- headers: this.headers,
- };
+ // this.loggedUserChat = authService.ValidatedUserChat;
+ // this.headers = new HttpHeaders();
+ // this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId);
+ // this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
+ // this.options = {
+ // headers: this.headers,
+ // };
}
diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts
index 74e52a2e8..f181a90a7 100644
--- a/src/app/services/chat/message.service.ts
+++ b/src/app/services/chat/message.service.ts
@@ -18,7 +18,13 @@ export class MessageService {
msg = ''
rid = ''
ts = {}
- u = {}
+
+ u = {
+ name: '',
+ username: '',
+ _id: ""
+ }
+
t = ''
_id =''
_updatedAt
@@ -35,6 +41,8 @@ export class MessageService {
loadHistory = false
duration = ''
localReference = null
+ viewed = []
+ received = []
constructor(private storage: Storage,
private NfService: NfService,
@@ -78,6 +86,7 @@ export class MessageService {
}
}
+
this.calDateDuration()
}
@@ -140,9 +149,9 @@ export class MessageService {
console.log('message', message)
let ChatMessage = message.result
-
+
if (environment.chatOffline) {
- // this.redefinedMessage(ChatMessage)
+ this.redefinedMessage(ChatMessage)
this.offline = false
}
@@ -189,5 +198,47 @@ export class MessageService {
this.duration = showDateDuration(date || this._updatedAt);
}
+ private messageReceptor() {
+ return this.u.username != SessionStore.user.RochetChatUser
+ }
+
+ receptorReceive() {
+
+ if(this.messageReceptor()) {
+ let newMessage = {
+ rid: this._id,
+ msg: this.msg,
+ attachments: this.attachments,
+ file: this.file,
+ localReference: this.localReference,
+ viewed: this.viewed.push('123'),
+ received: this.viewed.push('123'),
+ }
+
+ this.WsChatService.updateMessage(newMessage).then(()=>{
+ console.log('newMessage', newMessage)
+ })
+ }
+
+ }
+
+ receptorView() {
+ if(this.messageReceptor()) {
+ let newMessage = {
+ rid: this._id,
+ msg: this.msg,
+ attachments: this.attachments,
+ file: this.file,
+ localReference: this.localReference,
+ viewed: this.viewed.push('123'),
+ received: this.viewed.push('123'),
+ }
+
+ this.WsChatService.updateMessage(newMessage).then(()=>{
+ console.log('newMessage', newMessage)
+ })
+ }
+
+ }
}
diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts
index 925b26eea..d6a3aba39 100644
--- a/src/app/services/chat/room.service.ts
+++ b/src/app/services/chat/room.service.ts
@@ -201,6 +201,40 @@ export class RoomService {
})
}
+ }
+
+ async updateViewedMessage(id, userId) {
+ if (environment.chatOffline) {
+ this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
+ if(!Array.isArray(messages)) {
+ messages = []
+ }
+
+ let index;
+ const find = messages.find((message, _index)=> {
+
+ if(message._id == id) {
+ index = _index
+ return true
+ }
+
+ return false
+ })
+
+ if(find) {
+
+ if(!messages[index].hasOwnProperty('viewed') || !Array.isArray(messages[index].viewed)) {
+ messages.viewed = []
+ }
+
+ messages.viewed.push(userId)
+ this.storage.set('chatmsg' + this.id, messages)
+
+ }
+
+ })
+ }
+
}
/**
@@ -279,11 +313,16 @@ export class RoomService {
attachments,
file,
temporaryData,
- localReference
+ localReference,
+ viewed: [],
+ received: []
}
const message: MessageService = this.prepareMessage(offlineChatMessage, environment.chatOffline)
+ /**
+ * @description redefine message offline data "offlineChatMessage" with live ChatMessage
+ */
message.send().then((ChatMessage) => {
this.updateMessageDB(ChatMessage, localReference)
})
@@ -305,6 +344,13 @@ export class RoomService {
this.message= ''
}
+
+ /**
+ *
+ * @param message
+ * @param ChatMessage
+ * @description when creating message we use offline data, then we need redefined with live data
+ */
redefinedMessage (message: MessageService, ChatMessage) {
ChatMessage = this.fix_updatedAt(ChatMessage)
@@ -448,7 +494,12 @@ export class RoomService {
}
-
+ /**
+ * @description find or create message
+ * @param message
+ * @param save
+ * @returns
+ */
prepareMessage(message, save = true): MessageService {
message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService)
diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts
index a276e2417..d541b7ce9 100644
--- a/src/app/services/chat/ws-chat-methods.service.ts
+++ b/src/app/services/chat/ws-chat-methods.service.ts
@@ -22,8 +22,8 @@ export class WsChatMethodsService {
dm: {[key: string]: RoomService} = {}
group: {[key: string]: RoomService} = {}
- _dm = []
- _group = []
+ _dm: RoomService[] = []
+ _group: RoomService[] = []
loadingWholeList = false
@@ -71,7 +71,9 @@ export class WsChatMethodsService {
}
})
- this.changeProfileService.registerCallback(()=>{
+
+ // on change profile remove a rooms
+ this.changeProfileService.registerCallback(() => {
this.clearChat()
this.ReLoadChat()
this.storage.remove('Rooms');
@@ -142,13 +144,6 @@ export class WsChatMethodsService {
this.users = []
}
- getRoomFromDb() {
- this.storage.get('Rooms').then((rooms) => {
- rooms.result.update.forEach((roomData: room) => {
- this.prepareRoom(roomData);
- });
- })
- }
openRoom(roomId) {
@@ -186,7 +181,6 @@ export class WsChatMethodsService {
async getAllRooms () {
this.loadingWholeList = true
- //this.getRoomFromDb();
const rooms = await this.WsChatService.getRooms();
await this.storage.remove('Rooms');
await this.storage.set('Rooms', rooms);
@@ -266,6 +260,9 @@ export class WsChatMethodsService {
prepareRoom(roomData) {
+ /**
+ * @description data used to define or create room
+ */
const setData = {
customFields: roomData.customFields,
id: this.getRoomId(roomData),
@@ -277,14 +274,16 @@ export class WsChatMethodsService {
let roomId = this.getRoomId(roomData)
- if(!this.dm[roomId] && !this.group[roomId]) {
+ // create room
+ if(!this.roomExist(roomId)) {
let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService)
room.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
room.receiveMessageDelete();
room.sortRoomList = this.sortRoomList
-
+
+ // create individual room
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
@@ -292,12 +291,16 @@ export class WsChatMethodsService {
this.dmCount++
} else {
+ // create group room
+
this.group[roomId] = room
this._group.push(room)
this.groupCount++
}
} else {
+ // in this case room is already present, therefor it will only be necessary,
+ // to redefine
if(this.dm[roomId]) {
this.dm[roomId].setData(setData)
@@ -306,11 +309,11 @@ export class WsChatMethodsService {
}
}
-
-
}
-
+ roomExist(roomId) {
+ return this.dm[roomId] && this.group[roomId]
+ }
getReceptorName(roomData) {
try {
@@ -326,20 +329,20 @@ export class WsChatMethodsService {
*/
private getUserStatus(id?:string) {
- // this.WsChatService.getUserStatus((d) => {
+ this.WsChatService.getUserStatus((d) => {
- // const username = d.fields.args[0][1]
- // const statusNum = d.fields.args[0][2]
+ const username = d.fields.args[0][1]
+ const statusNum = d.fields.args[0][2]
- // const statusText = this.statusNumberToText(statusNum)
+ const statusText = this.statusNumberToText(statusNum)
- // const user = this.getUserByName(username)
+ const user = this.getUserByName(username)
- // if(user) {
- // user.status = statusText
- // }
+ if(user) {
+ user.status = statusText
+ }
- // })
+ })
}
@@ -377,7 +380,11 @@ export class WsChatMethodsService {
}
hidingRoom(id?) {
- return this.WsChatService.hidingRoom(id);
+
+ return this.WsChatService.hidingRoom(id).then(()=>{
+ // this.hideRoom(id)
+ })
+
}
addRoomOwner(roomid, userId){
@@ -403,7 +410,7 @@ export class WsChatMethodsService {
getRoomName(roomData: room) {
if(this.isIndividual(roomData)) {
const names: String[] = roomData.usernames
- const roomName = names.filter((name)=>{
+ const roomName = names.filter((name, index)=>{
return name != SessionStore.user.RochetChatUser
})[0]
diff --git a/src/app/services/chat/ws-chat.service.ts b/src/app/services/chat/ws-chat.service.ts
index 8b3633909..d6f8908dd 100644
--- a/src/app/services/chat/ws-chat.service.ts
+++ b/src/app/services/chat/ws-chat.service.ts
@@ -186,6 +186,29 @@ export class WsChatService {
});
}
+ updateMessage(messageObject) {
+
+ const requestId = uuidv4()
+ var message = {
+ msg: "method",
+ method: "updateMessage",
+ id: requestId,
+ params: [messageObject]
+ }
+
+ this.ws.send({message, requestId});
+
+ return new Promise((resolve, reject) => {
+ this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
+ if(message.id == requestId ) { // same request send
+ resolve({message, requestId})
+ return true
+ }
+ }})
+ })
+
+ }
+
leaveRoom(roomId) {
const requestId = uuidv4()
diff --git a/src/app/services/route.service.ts b/src/app/services/route.service.ts
index d1531e0e6..54bcf24d3 100644
--- a/src/app/services/route.service.ts
+++ b/src/app/services/route.service.ts
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
-import { NavigationEnd, Router, NavigationStart } from '@angular/router';
-
+import { NavigationEnd, Router, NavigationStart, NavigationExtras } from '@angular/router';
+import { LocalstoreService } from '../store/localstore.service';
+import { Location } from '@angular/common'
@Injectable({
providedIn: 'root'
@@ -12,7 +13,12 @@ export class RouteService {
constructor(
private router: Router,
+ private LocalstoreService: LocalstoreService,
+ private Location: Location
) {
+
+ this.history = this.LocalstoreService.get('history', [])
+
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd) {
@@ -20,6 +26,7 @@ export class RouteService {
if(event.url != lastRoute) {
this.history.push(event.url)
+ this.LocalstoreService.set('history', this.history)
}
}
@@ -30,19 +37,23 @@ export class RouteService {
}
/**
- * @param url [string] incase no history to go back
- * @param option [Object] some options to the url
- */
- goBack(url = null, option: object = {}) {
+ * @param url [string] incase no history to go back */
+ goBack(url = null) {
if(this.history.length >= 2) {
this.history.pop();
const goTo = this.history.pop();
- this.isGoBack = true;
- this.router.navigate([goTo]);
+
+ this.Location.back()
+
} else if(url) {
this.goTo({url})
}
+ if(this.history.length >= 15) {
+ this.history = this.history.slice(5, this.history.length)
+ }
+
+ this.LocalstoreService.set('history', this.history)
}
goTo({url}) {
diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html
index 65c1e02fb..b23e15fd4 100644
--- a/src/app/shared/chat/messages/messages.page.html
+++ b/src/app/shared/chat/messages/messages.page.html
@@ -48,11 +48,16 @@
- {{msg.u.name}}
+ {{msg.u.name}}
{{msg.duration}}
-
-
{{msg.msg}}
+
+ {{msg.msg}}
+
+
+
+
+
{{last ? scrollToBottom() : ''}}
@@ -75,6 +80,11 @@

+
+
+
+
+
@@ -99,6 +109,11 @@
{{msg.displayType}}
+
+
+
+
+
diff --git a/src/app/shared/chat/messages/messages.page.scss b/src/app/shared/chat/messages/messages.page.scss
index 5dc3040c6..6dd7ecd97 100644
--- a/src/app/shared/chat/messages/messages.page.scss
+++ b/src/app/shared/chat/messages/messages.page.scss
@@ -287,3 +287,29 @@ display: block;
padding-left: 10px;
}
+.float-status{
+ position: relative !important;
+ float: right;
+ display: flex;
+ align-items: self-end;
+}
+
+.float-status-image{
+ position: relative !important;
+ float: right;
+ display: flex;
+ align-items: self-end;
+ top: -15px;
+}
+
+.float-status-webtrix {
+ position: relative !important;
+ top: 0px !important;
+ float: right;
+ display: flex;
+ align-items: self-end;
+}
+
+.float-status-all {
+ font-size: 10pt !important;
+}
\ No newline at end of file
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts
index 25e4d7e6e..4642904b9 100644
--- a/src/app/shared/chat/messages/messages.page.ts
+++ b/src/app/shared/chat/messages/messages.page.ts
@@ -773,6 +773,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
}
+
+
+ testEditMessage(msg:MessageService) {
+ msg.receptorReceive()
+ // alert('cool!')
+ }
}
diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
index 34a6c3042..04f9cd18a 100644
--- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
+++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
@@ -18,8 +18,8 @@ import { Storage } from '@ionic/storage';
export class EventsToApprovePage implements OnInit {
showLoader: boolean;
- eventsPRList: any;
- eventsMDGPRList: any;
+ eventsPRList: any = []
+ eventsMDGPRList: any = []
eventPerson: EventPerson;
eventBody: EventBody;
categories: string[];
@@ -155,6 +155,10 @@ export class EventsToApprovePage implements OnInit {
}
close(){
this.modalController.dismiss(null);
+
+
+
+ // this.RouteService.goBack('/home/gabinetedigital')
}
diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html
index 34d0f448b..3cb36c948 100644
--- a/src/app/shared/header/header.page.html
+++ b/src/app/shared/header/header.page.html
@@ -133,4 +133,5 @@