This commit is contained in:
Peter Maquiran
2022-02-10 20:16:15 +01:00
24 changed files with 400 additions and 257 deletions
+9 -10
View File
@@ -112,7 +112,7 @@ export class AuthService {
//user: UserForm
async loginChat() {
const expirationMinutes = 60;
const expirationMinutes = 30;
let date = new Date().getTime();
let expirationDate = new Date(new Date().getTime() + expirationMinutes*60*1000);
@@ -125,8 +125,6 @@ export class AuthService {
if(responseChat) {
this.loginToChatWs()
console.log('Login to Rocket chat OK', responseChat);
this.ValidatedUserChat = responseChat;
localStorage.setItem('userChat', JSON.stringify(responseChat));
@@ -146,7 +144,7 @@ export class AuthService {
}, expirationDate)
}
private loginToChatWs() {
loginToChatWs() {
setTimeout(()=>{
this.WsChatService.connect();
@@ -167,6 +165,7 @@ export class AuthService {
try {
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
message.file.guid = guid.path
alert('uploaded')
await this.storage.set(guid.path, message.file.image_url).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
@@ -199,7 +198,7 @@ export class AuthService {
}
this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => {
this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => {
console.log('FILE TYPE', message.file.type)
let downloadFile = "";
@@ -207,20 +206,20 @@ export class AuthService {
const event: any = await this.AttachmentsService.downloadFile(message.file.guid).toPromise();
console.log('FILE TYPE 22', message.file.guid)
if (event.type === HttpEventType.DownloadProgress) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
console.log('FILE TYPE 33', message.file.type)
return true
} else if (event.type === HttpEventType.Response) {
downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
message.file = {
guid: message.file.guid,
image_url: downloadFile,
type: message.file.type
}
await this.storage.set(message.file.guid, downloadFile).then(() => {
console.log('IMAGE SAVED')
});
@@ -228,10 +227,10 @@ export class AuthService {
}
return false
}
};
}, 1)