This commit is contained in:
Peter Maquiran
2022-03-28 16:37:32 +01:00
parent 18797a43ff
commit 2fab7e01d5
5 changed files with 36 additions and 33 deletions
+4 -6
View File
@@ -12,12 +12,12 @@ export class MessageModel extends models.Model {
rid = models.CharField()
ts = JsonField({blank:true})
u = JsonField()
_id = models.CharField({unique:true, blank:true})
_id = models.CharField({blank:true})
_updatedAt = models.IntegerField()
messageSend = models.BooleanField()
offline = models.BooleanField()
viewed = ArrayField()
received = ArrayField()
viewed = ArrayField({blank:true})
received = ArrayField({blank:true})
localReference = models.CharField({blank:true})
attachments = ArrayField({blank:true})
file = JsonField({blank:true})
@@ -28,10 +28,8 @@ export class DeleteMessageModel extends models.Model {
messageId = models.CharField()
rid = models.CharField()
ts = JsonField()
u = JsonField()
needToReceiveBy = ArrayField()
}
@@ -39,6 +37,6 @@ export class DeleteMessageModel extends models.Model {
models.register({
databaseName: 'chat-storage',
type: 'indexedDB',
version: 1,
version: 4,
models: [MessageModel, DeleteMessageModel]
})
-3
View File
@@ -222,7 +222,6 @@ export class MessageService {
if (event.type === HttpEventType.DownloadProgress) {
console.log('FILE TYPE 33', this.file.type)
} else if (event.type === HttpEventType.Response) {
if (this.file.type == "application/img") {
downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
@@ -242,7 +241,6 @@ export class MessageService {
ts: this.attachments[0].ts
}
console.log(this.attachments)
// save the changes to the storage
this.save()
}
@@ -262,7 +260,6 @@ export class MessageService {
async delateDB() {
// alert('delete data')
const message = await MessageModel.get({_id: this._id})
await message.delete()
+18 -17
View File
@@ -394,13 +394,13 @@ export class RoomService {
this.messages[i]?.delateDB()
console.log(_id,'==',this.messages[i]?._id, true)
// console.log(_id,'==',this.messages[i]?._id, true)
this.messages.splice(i, 1)
return true
} else {
console.log(_id,'==',this.messages[i]?._id, false)
// console.log(_id,'==',this.messages[i]?._id, false)
}
}
@@ -430,19 +430,20 @@ export class RoomService {
await message.delateStatusFalse()
this.ChatMethodsService.deleteMessage({_id:msgId, msgId:msgId, roomId:message.rid}).subscribe(
(response: any) => {
async (response: any) => {
message.delateRequest = true
message.save()
await message.save()
this.deleteMessage(msgId)
},
(response) => {
async (response) => {
if (response.error.error.startsWith('No message found with the id of')) {
this.deleteMessage(msgId)
message.delateRequest = true
await message.save()
} else {
this.WsChatService.registerCallback({
@@ -626,25 +627,25 @@ export class RoomService {
await this.restoreMessageFromDB()
}
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
// await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
console.log('load chatHistory', JSON.stringify(chatHistory))
// console.log('load chatHistory', JSON.stringify(chatHistory))
const messagesId = this.messages.map((message)=> message._id)
// const messagesId = this.messages.map((message)=> message._id)
chatHistory.result.messages.reverse().forEach(async(message: any) => {
// chatHistory.result.messages.reverse().forEach(async(message: any) => {
if (!messagesId.includes(message._id)) {
const messagesToSave = await this.prepareMessageCreateIfNotExist_iD({message: message});
if(messagesToSave) {
await messagesToSave.addMessageDB()
}
}
// if (!messagesId.includes(message._id)) {
// const messagesToSave = await this.prepareMessageCreateIfNotExist_iD({message: message});
// if(messagesToSave) {
// await messagesToSave.addMessageDB()
// }
// }
})
// })
})
// })
setTimeout(() => {
this.scrollDown()
@@ -160,7 +160,10 @@ export class WsChatMethodsService {
} catch(e){}
this.sortRoomList()
setTimeout(()=>{
this.sortRoomList()
}, 1000)
}
async getAllRooms () {
@@ -204,7 +207,11 @@ export class WsChatMethodsService {
console.log('save rooms', rooms)
await this.storage.set('Rooms', rooms);
this.sortRoomList()
setTimeout(()=>{
this.sortRoomList()
}, 1000)
this.loadingWholeList = false
}
+5 -5
View File
@@ -4,12 +4,12 @@
export const environment = {
production: false,
apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/',
// apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/',
apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/',
//apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/',
apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/',
//apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/',
apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket',
//apiChatUrl: 'https://www.tabularium.pt/api/v1/',
/* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */
apiChatUrl: 'https://www.tabularium.pt/api/v1/',
//apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/',
domain: 'gabinetedigital.local', //gabinetedigital.local
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local
defaultuserpwd: 'tabteste@006', //tabteste@006,