diff --git a/src/app/Rules/despacho.service.ts b/src/app/Rules/despacho.service.ts
index ae89903af..2e41e5305 100644
--- a/src/app/Rules/despacho.service.ts
+++ b/src/app/Rules/despacho.service.ts
@@ -254,7 +254,7 @@ export class DespachoService {
});
despachoList = this.sortService.sortDate(despachoList, 'CreateDate')
-
+
if(updateStore) {
this.despachoStore.reset(despachoList);
}
diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts
index 3e8e940d4..5f8235fac 100644
--- a/src/app/services/chat/room.service.ts
+++ b/src/app/services/chat/room.service.ts
@@ -8,12 +8,13 @@ import { chatHistory, ChatMessage } from 'src/app/models/chatMethod'
import { Storage } from '@ionic/storage';
import { Platform } from '@ionic/angular';
import { SqliteService } from 'src/app/services/sqlite.service';
+import { SortService } from '../functions/sort.service';
@Injectable({
providedIn: 'root'
})
export class RoomService {
- massages: MessageService[] = []
+ messages: MessageService[] = []
storageMessage: any[] = [];
lastMessage: MessageService;
@@ -37,6 +38,7 @@ export class RoomService {
private storage: Storage,
private platform: Platform,
private sqlservice: SqliteService,
+ private sortService: SortService,
) { }
setData({ customFields, id, name, t, lastMessage = new MessageService(), _updatedAt }) {
@@ -67,12 +69,13 @@ export class RoomService {
this.lastMessage = message
if (message.t == 'r') { this.name = message.msg }
this.calDateDuration(ChatMessage._updatedAt)
- this.massages.push(message)
+ this.messages.push(message)
setTimeout(() => {
this.scrollDown()
}, 100)
+ //this.sortService.sortDate(this.messages, '')
// save to ionic storage
this.storage.get('chatmsg' + this.id).then((messages: any) => {
@@ -97,15 +100,15 @@ export class RoomService {
async (ChatMessage) => {
console.log(ChatMessage.fields.args[0]._id);
const messageId = ChatMessage.fields.args[0]._id;
- this.massages.forEach((message, index)=>{
+ this.messages.forEach((message, index)=>{
if(message._id == messageId){
- this.massages.splice(index, 1)
- this.storage.set('chatmsg' + this.id, this.massages).then((value) => {
+ this.messages.splice(index, 1)
+ this.storage.set('chatmsg' + this.id, this.messages).then((value) => {
//console.log('MSG DELETE ON STORAGE', value)
});
//Get previous last message from room
- const previousLastMessage = this.massages.slice(-1)[0];
+ const previousLastMessage = this.messages.slice(-1)[0];
this.lastMessage = previousLastMessage;
this.calDateDuration(previousLastMessage._updatedAt)
@@ -156,8 +159,8 @@ export class RoomService {
console.log('FROM DB WEB', mmessage)
const wewMessage = new MessageService()
wewMessage.setData(mmessage)
- this.massages.push(wewMessage)
- console.log('loadHistory 222', this.massages)
+ this.messages.push(wewMessage)
+ console.log('loadHistory 222', this.messages)
});
});
}
@@ -190,8 +193,8 @@ export class RoomService {
console.log('FROM DB WEB', mmessage)
const wewMessage = new MessageService()
wewMessage.setData(mmessage)
- this.massages.push(wewMessage)
- console.log('loadHistory 222', this.massages)
+ this.messages.push(wewMessage)
+ console.log('loadHistory 222', this.messages)
});
})
}
diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts
index d760efe42..7829b8b70 100644
--- a/src/app/services/chat/ws-chat-methods.service.ts
+++ b/src/app/services/chat/ws-chat-methods.service.ts
@@ -8,6 +8,7 @@ import { Rooms, Update as room } from 'src/app/models/chatMethod';
import { Storage } from '@ionic/storage';
import { Platform } from '@ionic/angular';
import { SqliteService } from 'src/app/services/sqlite.service';
+import { SortService } from '../functions/sort.service';
@Injectable({
providedIn: 'root'
@@ -29,6 +30,7 @@ export class WsChatMethodsService {
private storage: Storage,
private platform: Platform,
private sqlservice: SqliteService,
+ private sortService: SortService
) {
(async()=>{
await this.getAllRooms();
@@ -100,7 +102,7 @@ export class WsChatMethodsService {
prepareRoom(roomData){
let room:RoomService;
- room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice)
+ room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice, this.sortService)
room.setData({
customFields: roomData.customFields,
id: this.getRoomId(roomData),
diff --git a/src/app/services/functions/sort.service.ts b/src/app/services/functions/sort.service.ts
index c248ff958..dc4c4b84f 100644
--- a/src/app/services/functions/sort.service.ts
+++ b/src/app/services/functions/sort.service.ts
@@ -15,7 +15,7 @@ export class SortService {
});
}
}
-
+
sortArrayByDate(myArray: any) {
console.log(myArray[0].taskStartDate);
if(myArray.length > 0){
@@ -26,13 +26,8 @@ export class SortService {
}
sortDate(array = [], path: string) {
-
return array.sort( (a,b)=> {
-
- return new Date(this.ObjectService.deepFind(b, path)).getTime() -
- new Date(this.ObjectService.deepFind(a, path)).getTime()
-
+ return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime()
})
-
}
}
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 1f04ea84d..234c7876a 100644
--- a/src/app/shared/chat/group-messages/group-messages.page.html
+++ b/src/app/shared/chat/group-messages/group-messages.page.html
@@ -44,7 +44,7 @@