mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
save
This commit is contained in:
@@ -254,7 +254,7 @@ export class DespachoService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
despachoList = this.sortService.sortDate(despachoList, 'CreateDate')
|
despachoList = this.sortService.sortDate(despachoList, 'CreateDate')
|
||||||
|
|
||||||
if(updateStore) {
|
if(updateStore) {
|
||||||
this.despachoStore.reset(despachoList);
|
this.despachoStore.reset(despachoList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import { chatHistory, ChatMessage } from 'src/app/models/chatMethod'
|
|||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
import { Platform } from '@ionic/angular';
|
import { Platform } from '@ionic/angular';
|
||||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||||
|
import { SortService } from '../functions/sort.service';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class RoomService {
|
export class RoomService {
|
||||||
|
|
||||||
massages: MessageService[] = []
|
messages: MessageService[] = []
|
||||||
storageMessage: any[] = [];
|
storageMessage: any[] = [];
|
||||||
lastMessage: MessageService;
|
lastMessage: MessageService;
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ export class RoomService {
|
|||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
private platform: Platform,
|
private platform: Platform,
|
||||||
private sqlservice: SqliteService,
|
private sqlservice: SqliteService,
|
||||||
|
private sortService: SortService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
setData({ customFields, id, name, t, lastMessage = new MessageService(), _updatedAt }) {
|
setData({ customFields, id, name, t, lastMessage = new MessageService(), _updatedAt }) {
|
||||||
@@ -67,12 +69,13 @@ export class RoomService {
|
|||||||
this.lastMessage = message
|
this.lastMessage = message
|
||||||
if (message.t == 'r') { this.name = message.msg }
|
if (message.t == 'r') { this.name = message.msg }
|
||||||
this.calDateDuration(ChatMessage._updatedAt)
|
this.calDateDuration(ChatMessage._updatedAt)
|
||||||
this.massages.push(message)
|
this.messages.push(message)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollDown()
|
this.scrollDown()
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
|
//this.sortService.sortDate(this.messages, '')
|
||||||
|
|
||||||
// save to ionic storage
|
// save to ionic storage
|
||||||
this.storage.get('chatmsg' + this.id).then((messages: any) => {
|
this.storage.get('chatmsg' + this.id).then((messages: any) => {
|
||||||
@@ -97,15 +100,15 @@ export class RoomService {
|
|||||||
async (ChatMessage) => {
|
async (ChatMessage) => {
|
||||||
console.log(ChatMessage.fields.args[0]._id);
|
console.log(ChatMessage.fields.args[0]._id);
|
||||||
const messageId = 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){
|
if(message._id == messageId){
|
||||||
this.massages.splice(index, 1)
|
this.messages.splice(index, 1)
|
||||||
this.storage.set('chatmsg' + this.id, this.massages).then((value) => {
|
this.storage.set('chatmsg' + this.id, this.messages).then((value) => {
|
||||||
//console.log('MSG DELETE ON STORAGE', value)
|
//console.log('MSG DELETE ON STORAGE', value)
|
||||||
});
|
});
|
||||||
|
|
||||||
//Get previous last message from room
|
//Get previous last message from room
|
||||||
const previousLastMessage = this.massages.slice(-1)[0];
|
const previousLastMessage = this.messages.slice(-1)[0];
|
||||||
|
|
||||||
this.lastMessage = previousLastMessage;
|
this.lastMessage = previousLastMessage;
|
||||||
this.calDateDuration(previousLastMessage._updatedAt)
|
this.calDateDuration(previousLastMessage._updatedAt)
|
||||||
@@ -156,8 +159,8 @@ export class RoomService {
|
|||||||
console.log('FROM DB WEB', mmessage)
|
console.log('FROM DB WEB', mmessage)
|
||||||
const wewMessage = new MessageService()
|
const wewMessage = new MessageService()
|
||||||
wewMessage.setData(mmessage)
|
wewMessage.setData(mmessage)
|
||||||
this.massages.push(wewMessage)
|
this.messages.push(wewMessage)
|
||||||
console.log('loadHistory 222', this.massages)
|
console.log('loadHistory 222', this.messages)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -190,8 +193,8 @@ export class RoomService {
|
|||||||
console.log('FROM DB WEB', mmessage)
|
console.log('FROM DB WEB', mmessage)
|
||||||
const wewMessage = new MessageService()
|
const wewMessage = new MessageService()
|
||||||
wewMessage.setData(mmessage)
|
wewMessage.setData(mmessage)
|
||||||
this.massages.push(wewMessage)
|
this.messages.push(wewMessage)
|
||||||
console.log('loadHistory 222', this.massages)
|
console.log('loadHistory 222', this.messages)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { Rooms, Update as room } from 'src/app/models/chatMethod';
|
|||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
import { Platform } from '@ionic/angular';
|
import { Platform } from '@ionic/angular';
|
||||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||||
|
import { SortService } from '../functions/sort.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -29,6 +30,7 @@ export class WsChatMethodsService {
|
|||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
private platform: Platform,
|
private platform: Platform,
|
||||||
private sqlservice: SqliteService,
|
private sqlservice: SqliteService,
|
||||||
|
private sortService: SortService
|
||||||
) {
|
) {
|
||||||
(async()=>{
|
(async()=>{
|
||||||
await this.getAllRooms();
|
await this.getAllRooms();
|
||||||
@@ -100,7 +102,7 @@ export class WsChatMethodsService {
|
|||||||
prepareRoom(roomData){
|
prepareRoom(roomData){
|
||||||
let room:RoomService;
|
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({
|
room.setData({
|
||||||
customFields: roomData.customFields,
|
customFields: roomData.customFields,
|
||||||
id: this.getRoomId(roomData),
|
id: this.getRoomId(roomData),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export class SortService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sortArrayByDate(myArray: any) {
|
sortArrayByDate(myArray: any) {
|
||||||
console.log(myArray[0].taskStartDate);
|
console.log(myArray[0].taskStartDate);
|
||||||
if(myArray.length > 0){
|
if(myArray.length > 0){
|
||||||
@@ -26,13 +26,8 @@ export class SortService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sortDate(array = [], path: string) {
|
sortDate(array = [], path: string) {
|
||||||
|
|
||||||
return array.sort( (a,b)=> {
|
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()
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
|
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last">
|
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).messages; let last = last">
|
||||||
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" >
|
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" >
|
||||||
<div class="message-item-options d-flex justify-content-end">
|
<div class="message-item-options d-flex justify-content-end">
|
||||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
//this.scrollToBottom();
|
//this.scrollToBottom();
|
||||||
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
|
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
|
||||||
this.wsChatMethodsService.getGroupRoom(this.roomId).getMsgFromDB();
|
this.wsChatMethodsService.getGroupRoom(this.roomId).getMsgFromDB();
|
||||||
console.log('MESSAGES'+ this.wsChatMethodsService.getGroupRoom(this.roomId).massages);
|
console.log('MESSAGES'+ this.wsChatMethodsService.getGroupRoom(this.roomId).messages);
|
||||||
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||||
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
</ion-refresher-content>
|
</ion-refresher-content>
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<div class="messages" #scrollMe>
|
<div class="messages" #scrollMe>
|
||||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).massages; let last = last">
|
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).messages; let last = last">
|
||||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''">
|
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''">
|
||||||
<div class="message-item-options d-flex justify-content-end">
|
<div class="message-item-options d-flex justify-content-end">
|
||||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
|
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
|
||||||
|
|||||||
Reference in New Issue
Block a user