clean code
This commit is contained in:
parent
af86c48aa8
commit
c4a6541ccb
3 changed files with 19 additions and 37 deletions
|
|
@ -18,7 +18,6 @@ export class AttachmentsComponent {
|
||||||
@Input() openOnSecondaryChat: boolean = false;
|
@Input() openOnSecondaryChat: boolean = false;
|
||||||
@Input() viewWidth: number = 0;
|
@Input() viewWidth: number = 0;
|
||||||
loadingUrl: string = './../../../assets/img/loading.svg';
|
loadingUrl: string = './../../../assets/img/loading.svg';
|
||||||
cachedImageUrl: string | null = null;
|
|
||||||
imageUrl: string | null = '';
|
imageUrl: string | null = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -31,17 +30,9 @@ export class AttachmentsComponent {
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
if (this.filePath) {
|
if (this.filePath) {
|
||||||
// Überprüfen Sie, ob der Bild-URL bereits im Cache vorhanden ist
|
this.imageUrl = await this.downloadFilesService.downloadFiles(
|
||||||
if (!this.cachedImageUrl) {
|
this.filePath
|
||||||
// Wenn nicht, laden Sie ihn herunter und speichern Sie ihn im Cache
|
);
|
||||||
this.cachedImageUrl = await this.downloadFilesService.downloadFiles(
|
|
||||||
this.filePath
|
|
||||||
);
|
|
||||||
console.log('1');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verwenden Sie den gecachten Bild-URL
|
|
||||||
this.imageUrl = this.cachedImageUrl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
getDownloadURL,
|
getDownloadURL,
|
||||||
getMetadata,
|
|
||||||
getStorage,
|
getStorage,
|
||||||
listAll,
|
listAll,
|
||||||
ref,
|
ref,
|
||||||
|
|
@ -23,21 +22,21 @@ export class DownloadFilesService {
|
||||||
this.listAllFiles();
|
this.listAllFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkChatHasFiles(chatId: string) {
|
async checkChatHasFiles(chatId: string): Promise<string | undefined> {
|
||||||
const storage = getStorage();
|
try {
|
||||||
const listRef = ref(storage, `chatFiles/${chatId}`);
|
const storage = getStorage();
|
||||||
return listAll(listRef)
|
const listRef = ref(storage, `chatFiles/${chatId}`);
|
||||||
.then((result) => {
|
|
||||||
if (result.items.length > 0) {
|
const result = await listAll(listRef);
|
||||||
return result.items[0].fullPath;
|
if (result.items.length > 0) {
|
||||||
} else {
|
return result.items[0].fullPath;
|
||||||
return undefined;
|
} else {
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Error listing files:', error);
|
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error listing files:', error);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import { Component, HostListener, OnInit } from '@angular/core';
|
||||||
Component,
|
|
||||||
HostListener,
|
|
||||||
OnInit
|
|
||||||
} from '@angular/core';
|
|
||||||
import { OverlayService } from '../../../service/overlay.service';
|
import { OverlayService } from '../../../service/overlay.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { SmallBtnComponent } from '../small-btn/small-btn.component';
|
import { SmallBtnComponent } from '../small-btn/small-btn.component';
|
||||||
|
|
@ -19,7 +15,6 @@ export class OverlayComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private overlayService: OverlayService) {}
|
constructor(private overlayService: OverlayService) {}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the component and subscribes to overlay data changes.
|
* Initializes the component and subscribes to overlay data changes.
|
||||||
*/
|
*/
|
||||||
|
|
@ -29,7 +24,6 @@ export class OverlayComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the file type from the file name.
|
* Extracts the file type from the file name.
|
||||||
* @param file The file name.
|
* @param file The file name.
|
||||||
|
|
@ -41,7 +35,6 @@ export class OverlayComponent implements OnInit {
|
||||||
return getTag || '';
|
return getTag || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the overlay.
|
* Closes the overlay.
|
||||||
*/
|
*/
|
||||||
|
|
@ -49,7 +42,6 @@ export class OverlayComponent implements OnInit {
|
||||||
this.overlayData = '';
|
this.overlayData = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the contact edit overlay is open and closes it if the click is outside the overlay content.
|
* Checks if the contact edit overlay is open and closes it if the click is outside the overlay content.
|
||||||
* @param event The mouse event.
|
* @param event The mouse event.
|
||||||
|
|
@ -59,7 +51,7 @@ export class OverlayComponent implements OnInit {
|
||||||
const targetElement = event.target as HTMLElement;
|
const targetElement = event.target as HTMLElement;
|
||||||
if (
|
if (
|
||||||
!targetElement.closest('.overlayContent') &&
|
!targetElement.closest('.overlayContent') &&
|
||||||
!targetElement.closest('.attachments')
|
!targetElement.closest('.files')
|
||||||
) {
|
) {
|
||||||
this.onCloseOverlay();
|
this.onCloseOverlay();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue