mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
performace
This commit is contained in:
Generated
+11
-15
@@ -71,7 +71,7 @@
|
||||
"@ionic-native/local-notifications": "^4.20.0",
|
||||
"@ionic-native/media": "^5.36.0",
|
||||
"@ionic-native/media-capture": "^5.36.0",
|
||||
"@ionic-native/network": "^5.22.0-beta-1",
|
||||
"@ionic-native/network": "^5.36.0",
|
||||
"@ionic-native/photo-viewer": "^5.36.0",
|
||||
"@ionic-native/screen-orientation": "^5.35.0",
|
||||
"@ionic-native/social-sharing": "^5.36.0",
|
||||
@@ -135,7 +135,6 @@
|
||||
"howler": "^2.2.3",
|
||||
"http-server": "^14.1.1",
|
||||
"husky": "^8.0.2",
|
||||
"i": "^0.3.7",
|
||||
"ionic-angular": "^3.9.10",
|
||||
"ionic-image-loader": "^6.3.3",
|
||||
"ionic-image-loader-v5": "^1.0.2",
|
||||
@@ -4692,8 +4691,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@ionic-native/network": {
|
||||
"version": "5.22.0-beta-1",
|
||||
"license": "MIT",
|
||||
"version": "5.36.0",
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/network/-/network-5.36.0.tgz",
|
||||
"integrity": "sha512-gpa7cJqodEK+zmmViYJCqEpXoKSXcaYLaaRKdv5gn5M++bpmiw2pKM9JH8VoqYWaYDcUwD3S0yYeBBkG5DE0Kg==",
|
||||
"dependencies": {
|
||||
"@types/cordova": "latest"
|
||||
},
|
||||
@@ -11990,8 +11990,9 @@
|
||||
},
|
||||
"node_modules/cordova-plugin-network-information": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-network-information/-/cordova-plugin-network-information-3.0.0.tgz",
|
||||
"integrity": "sha512-bBtP3PxIX8vshsfR0+F6co2e2cFLgjt18yKIdigzMwk6ANudWQ72RB3g2qMPyT6fBDWmUyE1Qd+bKQB/fZtQwQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
"3.0.0": {
|
||||
@@ -16325,12 +16326,6 @@
|
||||
"url": "https://github.com/sponsors/typicode"
|
||||
}
|
||||
},
|
||||
"node_modules/i": {
|
||||
"version": "0.3.7",
|
||||
"engines": {
|
||||
"node": ">=0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"license": "MIT",
|
||||
@@ -43726,7 +43721,9 @@
|
||||
}
|
||||
},
|
||||
"@ionic-native/network": {
|
||||
"version": "5.22.0-beta-1",
|
||||
"version": "5.36.0",
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/network/-/network-5.36.0.tgz",
|
||||
"integrity": "sha512-gpa7cJqodEK+zmmViYJCqEpXoKSXcaYLaaRKdv5gn5M++bpmiw2pKM9JH8VoqYWaYDcUwD3S0yYeBBkG5DE0Kg==",
|
||||
"requires": {
|
||||
"@types/cordova": "latest"
|
||||
}
|
||||
@@ -48906,6 +48903,8 @@
|
||||
},
|
||||
"cordova-plugin-network-information": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-network-information/-/cordova-plugin-network-information-3.0.0.tgz",
|
||||
"integrity": "sha512-bBtP3PxIX8vshsfR0+F6co2e2cFLgjt18yKIdigzMwk6ANudWQ72RB3g2qMPyT6fBDWmUyE1Qd+bKQB/fZtQwQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cordova-plugin-okhttp": {
|
||||
@@ -51796,9 +51795,6 @@
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.2.tgz",
|
||||
"integrity": "sha512-Tkv80jtvbnkK3mYWxPZePGFpQ/tT3HNSs/sasF9P2YfkMezDl3ON37YN6jUUI4eTg5LcyVynlb6r4eyvOmspvg=="
|
||||
},
|
||||
"i": {
|
||||
"version": "0.3.7"
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"requires": {
|
||||
|
||||
+1
-2
@@ -85,7 +85,7 @@
|
||||
"@ionic-native/local-notifications": "^4.20.0",
|
||||
"@ionic-native/media": "^5.36.0",
|
||||
"@ionic-native/media-capture": "^5.36.0",
|
||||
"@ionic-native/network": "^5.22.0-beta-1",
|
||||
"@ionic-native/network": "^5.36.0",
|
||||
"@ionic-native/photo-viewer": "^5.36.0",
|
||||
"@ionic-native/screen-orientation": "^5.35.0",
|
||||
"@ionic-native/social-sharing": "^5.36.0",
|
||||
@@ -149,7 +149,6 @@
|
||||
"howler": "^2.2.3",
|
||||
"http-server": "^14.1.1",
|
||||
"husky": "^8.0.2",
|
||||
"i": "^0.3.7",
|
||||
"ionic-angular": "^3.9.10",
|
||||
"ionic-image-loader": "^6.3.3",
|
||||
"ionic-image-loader-v5": "^1.0.2",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="middle-container" *ngIf="!showMessageOptions">
|
||||
<div class="middle">
|
||||
<ion-label class="title">{{ChatSystemService.getDmRoom(roomId).name}}</ion-label>
|
||||
<span><ion-icon class="{{ ChatSystemService.getDmRoom(this.roomId).online }}" name="ellipse"></ion-icon></span>
|
||||
<span><ion-icon *ngIf="RochetChatConnectorService.isLogin" class="{{ ChatSystemService.getDmRoom(this.roomId).online }}" name="ellipse"></ion-icon></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -115,7 +115,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
// private document: DocumentViewer
|
||||
private file: File,
|
||||
private fileOpener: FileOpener,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
public RochetChatConnectorService: RochetChatConnectorService,
|
||||
) {
|
||||
this.loggedUser = SessionStore.user.ChatData['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
|
||||
@@ -200,6 +200,7 @@ export class AuthService {
|
||||
message.file.guid = guid.path
|
||||
|
||||
message.downloadFileMsg()
|
||||
message.uploadingFile = false
|
||||
|
||||
return true
|
||||
} catch(e) {
|
||||
@@ -219,8 +220,9 @@ export class AuthService {
|
||||
message.attachments[0].title_link = url_no_options
|
||||
message.attachments[0].message_link = url_no_options
|
||||
|
||||
return true
|
||||
message.uploadingFile = false
|
||||
|
||||
return true
|
||||
} catch(e) {
|
||||
window['e'] = e
|
||||
console.error('BeforesendAtachment', e)
|
||||
|
||||
@@ -206,19 +206,15 @@ export class ChatSystemService {
|
||||
async restoreRooms() {
|
||||
|
||||
try {
|
||||
const rooms = await this.storage.get('Rooms');
|
||||
const _rooms = await this.storage.get('Rooms');
|
||||
|
||||
if(rooms) {
|
||||
for (let roomData of rooms.result.update) {
|
||||
if(_rooms) {
|
||||
for (let roomData of this.sortArrayISODate(_rooms)) {
|
||||
await this.prepareRoom(roomData);
|
||||
}
|
||||
}
|
||||
} catch(e){}
|
||||
|
||||
setTimeout(() => {
|
||||
this.sortRoomList()
|
||||
}, 10000)
|
||||
|
||||
}
|
||||
|
||||
async restoreUsers () {
|
||||
@@ -230,6 +226,14 @@ export class ChatSystemService {
|
||||
}
|
||||
}
|
||||
|
||||
sortArrayISODate(messages: any): any[] {
|
||||
|
||||
return messages.sort((a,b) =>
|
||||
new Date(b._updatedAt ).getTime()
|
||||
-
|
||||
new Date(a._updatedAt).getTime())
|
||||
}
|
||||
|
||||
async getAllRooms (callback:Function = () =>{} , roomIdCallback = "") {
|
||||
this.loadingWholeList = true
|
||||
var rooms;
|
||||
@@ -248,8 +252,17 @@ export class ChatSystemService {
|
||||
|
||||
let index = 0
|
||||
|
||||
if(rooms?.result?.update) {
|
||||
for (let roomData of rooms.result.update) {
|
||||
let _rooms = rooms?.result?.update
|
||||
|
||||
if(_rooms) {
|
||||
|
||||
_rooms = _rooms.map( e => {
|
||||
e["_updatedAt"] = e._updatedAt || e._updatedAt['$date']
|
||||
return e
|
||||
})
|
||||
|
||||
for (let roomData of this.sortArrayISODate(_rooms) ) {
|
||||
|
||||
|
||||
const roomId = this.getRoomId(roomData);
|
||||
|
||||
@@ -272,8 +285,8 @@ export class ChatSystemService {
|
||||
|
||||
const members = res['members'];
|
||||
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
|
||||
rooms.result.update[index]['members'] = members
|
||||
rooms.result.update[index]['membersExcludeMe'] = users
|
||||
_rooms[index]['members'] = members
|
||||
_rooms[index]['membersExcludeMe'] = users
|
||||
|
||||
await this.prepareRoom(roomData);
|
||||
} else {
|
||||
@@ -295,8 +308,8 @@ export class ChatSystemService {
|
||||
const members = res['members'];
|
||||
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
|
||||
|
||||
rooms.result.update[index]['members'] = members
|
||||
rooms.result.update[index]['membersExcludeMe'] = users
|
||||
_rooms[index]['members'] = members
|
||||
_rooms[index]['membersExcludeMe'] = users
|
||||
|
||||
await this.prepareRoom(roomData);
|
||||
|
||||
@@ -322,8 +335,8 @@ export class ChatSystemService {
|
||||
const members = res['members'];
|
||||
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
|
||||
|
||||
rooms.result.update[index]['members'] = members
|
||||
rooms.result.update[index]['membersExcludeMe'] = users
|
||||
_rooms[index]['members'] = members
|
||||
_rooms[index]['membersExcludeMe'] = users
|
||||
await this.prepareRoom(roomData);
|
||||
}
|
||||
|
||||
@@ -339,17 +352,8 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
this.loadingWholeList = false
|
||||
await this.storage.set('Rooms', rooms);
|
||||
|
||||
this.sortRoomList()
|
||||
|
||||
setTimeout(() => {
|
||||
this.sortRoomList()
|
||||
}, 1000)
|
||||
|
||||
setTimeout(() => {
|
||||
this.sortRoomList()
|
||||
}, 10000)
|
||||
await this.storage.set('Rooms', _rooms);
|
||||
|
||||
this.onRoomsLoad.executor()
|
||||
}
|
||||
|
||||
@@ -220,6 +220,7 @@ export class MessageService {
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
type: 'reConnect',
|
||||
funx: async () => {
|
||||
console.log('send now have login')
|
||||
this.send().catch((error) =>{
|
||||
console.error(error)
|
||||
})
|
||||
@@ -227,7 +228,16 @@ export class MessageService {
|
||||
}
|
||||
})
|
||||
|
||||
console.log('no login')
|
||||
|
||||
} else if (this.UploadAttachmentsTemp <= 3) {
|
||||
console.log('temp'+ this.UploadAttachmentsTemp)
|
||||
setTimeout(async () => {
|
||||
return await this.send()
|
||||
}, 4000)
|
||||
} else if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Offline) {
|
||||
|
||||
console.log('recooonect')
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
type: 'reConnect',
|
||||
funx: async ()=> {
|
||||
@@ -238,11 +248,8 @@ export class MessageService {
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else if (this.UploadAttachmentsTemp <= 3) {
|
||||
setTimeout(async () => {
|
||||
return await this.send()
|
||||
}, 3000)
|
||||
} else if (this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) {
|
||||
console.log('manual')
|
||||
this.manualRetry = true
|
||||
}
|
||||
|
||||
@@ -256,6 +263,7 @@ export class MessageService {
|
||||
|
||||
async sendRequestAttachment() {
|
||||
|
||||
console.log('sendRequestAttachment')
|
||||
this.uploadingFile = true
|
||||
|
||||
let uploadSuccessfully = false
|
||||
@@ -270,23 +278,30 @@ export class MessageService {
|
||||
await this.generateTemporaryData()
|
||||
}
|
||||
|
||||
console.log('send temp')
|
||||
if(this.hasSendAttachment == false) {
|
||||
try {
|
||||
uploadSuccessfully = await this.NfService.beforeSendAttachment(this)
|
||||
this.UploadAttachmentsTemp++
|
||||
this.uploadingFile = false
|
||||
|
||||
this.manualRetry = false
|
||||
this.errorUploadingAttachment = false
|
||||
this.hasSendAttachment = true
|
||||
this.UploadAttachmentsTemp++
|
||||
|
||||
uploadSuccessfully = await this.NfService.beforeSendAttachment(this)
|
||||
|
||||
this.uploadingFile = false
|
||||
this.hasSendAttachment = uploadSuccessfully
|
||||
|
||||
if(this.hasSendAttachment) {
|
||||
console.log('send uploadSuccessfully')
|
||||
} else {
|
||||
console.log('not send uploadSuccessfully')
|
||||
}
|
||||
|
||||
this.saveChanges()
|
||||
} catch (error) {
|
||||
this.uploadingFile = false
|
||||
|
||||
|
||||
console.log('send not uploadSuccessfully')
|
||||
this.errorUploadingAttachment = true
|
||||
this.UploadAttachmentsTemp++
|
||||
|
||||
this.saveChanges()
|
||||
}
|
||||
@@ -409,14 +424,14 @@ export class MessageService {
|
||||
|
||||
if(!roomObject.isGroup) {
|
||||
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
||||
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg,this.rid)
|
||||
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
|
||||
} else {
|
||||
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
||||
var usersNames = [];
|
||||
for(let i = 0; i < memeberTosend.length; i++) {
|
||||
usersNames.push(memeberTosend[i].username)
|
||||
}
|
||||
this.notificationService.ChatSendMessageNotificationGrup(usersNames,ChatMessage.u.name,ChatMessage.msg,this.rid)
|
||||
this.notificationService.ChatSendMessageNotificationGrup(usersNames,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -766,6 +766,7 @@ export class RochetChatConnectorService {
|
||||
setTimeout(()=>{
|
||||
this.ws.wsMsgQueue()
|
||||
}, 10)
|
||||
console.log('rec conect')
|
||||
|
||||
if(this.wsReconnect >= 1) {
|
||||
for (const [key, value] of Object.entries(this.wsCallbacks)) {
|
||||
|
||||
@@ -42,6 +42,7 @@ export class RoomService {
|
||||
name = ''
|
||||
_updatedAt = {}
|
||||
hasLoadHistory = false
|
||||
DoneLoadingHistory = false
|
||||
restoreFromOffline = false
|
||||
duration = ''
|
||||
isTyping = false
|
||||
@@ -327,7 +328,7 @@ export class RoomService {
|
||||
this.registerSendMessage(message)
|
||||
|
||||
message.from = 'stream'
|
||||
message.loadHistory = this.hasLoadHistory
|
||||
message.loadHistory = this.DoneLoadingHistory
|
||||
|
||||
this.lastMessage = message;
|
||||
this.calDateDuration(ChatMessage._updatedAt);
|
||||
@@ -352,6 +353,7 @@ export class RoomService {
|
||||
|
||||
this.messageUnread = true
|
||||
|
||||
// this.sortRoomList()
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 50)
|
||||
@@ -550,6 +552,30 @@ export class RoomService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description delete message in the view
|
||||
* @param id message ID
|
||||
*/
|
||||
async deleteMessageFromArray(_id) {
|
||||
|
||||
const id = _id
|
||||
|
||||
for (let i =0; i <= this.messages.length; i++) {
|
||||
|
||||
if(this.messages[i]?._id == id ) {
|
||||
|
||||
this.messages.splice(i, 1)
|
||||
|
||||
return true
|
||||
|
||||
} else {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
deleteAll() {
|
||||
this.messages.forEach((message) => {
|
||||
if(message?._id) {
|
||||
@@ -619,7 +645,7 @@ export class RoomService {
|
||||
}
|
||||
|
||||
|
||||
console.log('offlineChatMessage', offlineChatMessage)
|
||||
//console.log('offlineChatMessage', offlineChatMessage)
|
||||
|
||||
this.message= ''
|
||||
|
||||
@@ -792,7 +818,7 @@ export class RoomService {
|
||||
|
||||
this.messages.push(cloneMessage as any)
|
||||
|
||||
console.log(currentDateMessage)
|
||||
// console.log(currentDateMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -851,9 +877,6 @@ export class RoomService {
|
||||
|
||||
const messages = this.sortArrayISODate(await MessageModel.filter({rid:this.id}).execute()).reverse()
|
||||
|
||||
|
||||
console.log('MessageModel', messages)
|
||||
|
||||
for (let ChatMessage of messages) {
|
||||
|
||||
|
||||
@@ -907,6 +930,7 @@ export class RoomService {
|
||||
|
||||
// runs onces only
|
||||
loadHistoryCount = 0
|
||||
localMessages = []
|
||||
async loadHistory({limit = 1000, forceUpdate = false }) {
|
||||
|
||||
if(forceUpdate == false) {
|
||||
@@ -920,6 +944,8 @@ export class RoomService {
|
||||
await this.restoreMessageFromDB()
|
||||
const chatHistory: chatHistory = await this.RochetChatConnectorService.loadHistory(this.id, limit)
|
||||
|
||||
this.localMessages = this.messages.map( e => e._id)
|
||||
|
||||
if(chatHistory?.result?.messages) {
|
||||
|
||||
const users = this.getUsersByStatus('online')
|
||||
@@ -955,6 +981,8 @@ export class RoomService {
|
||||
|
||||
}
|
||||
|
||||
this.DoneLoadingHistory = true
|
||||
|
||||
if(chatHistory?.result?.messages) {
|
||||
|
||||
if(!this.lastMessage) {
|
||||
@@ -962,10 +990,31 @@ export class RoomService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.deletedMessages(chatHistory)
|
||||
}
|
||||
|
||||
|
||||
deletedMessages(chatHistory: chatHistory) {
|
||||
|
||||
const messagesToDelete = this.localMessages.filter( id => {
|
||||
const found = chatHistory.result.messages.find( e => {
|
||||
return e._id == id
|
||||
})
|
||||
if(!found) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
|
||||
for (const id of messagesToDelete) {
|
||||
if(id != '') {
|
||||
this.deleteMessage(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addMessageDB = FIFOProcessQueue(async ({messagesToSave}, callback) => {
|
||||
|
||||
await messagesToSave.addMessageDB()
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<ion-label class="title">{{ ChatSystemService.getGroupRoom(roomId).name.split('-').join(' ') }}</ion-label>
|
||||
</div>
|
||||
<div class="right">
|
||||
<!-- <div (click)=" ChatSystemService.getGroupRoom(this.roomId).deleteAll()">delete all</div> -->
|
||||
<button title="Menu" class="btn-no-color" (click)="openGroupMessagesOptions()">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-menu.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg"></ion-icon>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="middle">
|
||||
<ion-label class="title">{{ ChatSystemService.getDmRoom(this.roomId).name }}</ion-label>
|
||||
<!-- <button (click)="ChatMessageDebuggingPage()">Dev</button> -->
|
||||
<span><ion-icon class="{{ ChatSystemService.getDmRoom(this.roomId).online }}" name="ellipse"></ion-icon></span>
|
||||
<span><ion-icon *ngIf="RochetChatConnectorService.isLogin" class="{{ ChatSystemService.getDmRoom(this.roomId).online }}" name="ellipse"></ion-icon></span>
|
||||
</div>
|
||||
<div hidden class="right">
|
||||
<button title="Menu" class="btn-no-color" (click)="_openMessagesOptions()">
|
||||
@@ -37,6 +37,7 @@
|
||||
<div class="messages" #scrollMe>
|
||||
<ion-list>
|
||||
|
||||
<!-- <div (click)=" ChatSystemService.getDmRoom(this.roomId).deleteAll()">delete all</div> -->
|
||||
<div class="messages-list-item-wrapper container-width-100"
|
||||
*ngFor="let msg of ChatSystemService.getDmRoom(roomId).messages; index as i; let last = last" >
|
||||
|
||||
|
||||
Reference in New Issue
Block a user