mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Download file and display
This commit is contained in:
@@ -261,7 +261,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
getMessageDB() {
|
||||
this.storage.get('chatmsg').then((msg) => {
|
||||
this.storageservice.get('chatmsg').then((msg) => {
|
||||
console.log('FROM DB WEB', msg)
|
||||
let msgArray = [];
|
||||
msgArray = msg;
|
||||
@@ -272,21 +272,29 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
|
||||
getImageFromStorage (element) {
|
||||
let image;
|
||||
if (typeof element.file != 'undefined') {
|
||||
if (typeof element.file.guid != 'undefined') {
|
||||
let imageguid = this.storageservice.get(element.file.guid);
|
||||
if (imageguid) {
|
||||
image = imageguid;
|
||||
console.log('IMAGE STORAGE', image)
|
||||
} else {
|
||||
image = "";
|
||||
console.log('IMAGE STORAGE', image)
|
||||
}
|
||||
} else {
|
||||
image = "";
|
||||
}
|
||||
}
|
||||
console.log('IMAGE STORAGE RETURN', image.__zone_symbol__value)
|
||||
return image.__zone_symbol__value;
|
||||
}
|
||||
|
||||
transformData(res) {
|
||||
let mgsArray = [];
|
||||
res.forEach(async element => {
|
||||
let image;
|
||||
|
||||
if (element.file) {
|
||||
try {
|
||||
image = await this.storage.get(element.file.guid) ?? console.log('CHECK VALUE UNDEFINE');
|
||||
console.log('IMAGE STORAGE', image)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
let chatmsg = {
|
||||
_id: element._id,
|
||||
@@ -299,7 +307,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
ts: element.ts,
|
||||
u: element.u,
|
||||
_updatedAt: element._updatedAt,
|
||||
image_url: image,
|
||||
image_url: this.getImageFromStorage(element),
|
||||
}
|
||||
|
||||
mgsArray.push(chatmsg)
|
||||
@@ -307,10 +315,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
});
|
||||
console.log('Web TRANSFORM MSG', mgsArray)
|
||||
this.storage.remove('chatmsg').then(() => {
|
||||
this.storageservice.remove('chatmsg').then(() => {
|
||||
console.log('MSG REMOVE FROM STORAGE')
|
||||
});
|
||||
this.storage.set('chatmsg', mgsArray).then(() => {
|
||||
this.storageservice.store('chatmsg', mgsArray).then(() => {
|
||||
console.log('MSG SAVED ON STORAGE')
|
||||
this.getMessageDB();
|
||||
});
|
||||
@@ -372,7 +380,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
console.log('GET FILE WEB', foo)
|
||||
});
|
||||
|
||||
this.storage.get('chatmsg').then(async (msg) => {
|
||||
this.storageservice.get('chatmsg').then(async (msg) => {
|
||||
let msgArray = [];
|
||||
msgArray = msg;
|
||||
msgArray.filter(data => data._id != this.roomId);
|
||||
@@ -403,8 +411,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
});
|
||||
await this.storage.remove('chatmsg');
|
||||
await this.storage.set('chatmsg', newmgsArray);
|
||||
await this.storageservice.remove('chatmsg');
|
||||
await this.storageservice.store('chatmsg', newmgsArray);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -700,7 +708,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
/* this.transformData(res['messages']);
|
||||
this.getMessageDB(); */
|
||||
this.transformData(res['messages']);
|
||||
this.getMessageDB();
|
||||
this.getMessageDB();
|
||||
/*
|
||||
this.messages = res['messages'].reverse();
|
||||
this.chatMessageStore.add(roomId, this.messages) */
|
||||
@@ -789,7 +797,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
console.log('TRY ARRAY BUFFER NAME', name);
|
||||
console.log('TRY ARRAY BUFFER', this.downloadFile);
|
||||
|
||||
this.storage.set(msg.file.guid, this.downloadFile);
|
||||
this.storageservice.store(msg.file.guid, this.downloadFile);
|
||||
|
||||
await Filesystem.writeFile({
|
||||
path: `${IMAGE_DIR}/${name}`,
|
||||
|
||||
Reference in New Issue
Block a user