fixed favicon wrongly displaying for files

This commit is contained in:
0PandaDEV 2024-08-26 09:17:36 +10:00
parent 14fb5c37a9
commit a5102abe46
No known key found for this signature in database

13
app.vue
View file

@ -5,7 +5,7 @@
spellcheck="false" class="search" type="text" placeholder="Type to filter entries..."> spellcheck="false" class="search" type="text" placeholder="Type to filter entries...">
<div class="bottom-bar"> <div class="bottom-bar">
<div class="left"> <div class="left">
<img class="logo" width="18px" src="/Logo.svg" alt=""> <img class="logo" width="18px" src="/logo.png" alt="">
<p>Qopy</p> <p>Qopy</p>
</div> </div>
<div class="right"> <div class="right">
@ -33,7 +33,7 @@
@click="selectItem(groupIndex, index)" @click="selectItem(groupIndex, index)"
:ref="el => { if (isSelected(groupIndex, index)) selectedElement = el as HTMLElement }"> :ref="el => { if (isSelected(groupIndex, index)) selectedElement = el as HTMLElement }">
<img v-if="item.content_type === 'image'" :src="getComputedImageUrl(item)" alt="Image" class="favicon-image"> <img v-if="item.content_type === 'image'" :src="getComputedImageUrl(item)" alt="Image" class="favicon-image">
<img v-else-if="isUrl(item.content)" :src="getFaviconFromDb(item.favicon ?? '')" alt="Favicon" class="favicon"> <img v-else-if="hasFavicon(item.favicon ?? '')" :src="getFaviconFromDb(item.favicon ?? '')" alt="Favicon" class="favicon">
<FileIcon class="file" v-else /> <FileIcon class="file" v-else />
<span v-if="item.content_type === 'image'">Image ({{ item.dimensions || 'Loading...' }})</span> <span v-if="item.content_type === 'image'">Image ({{ item.dimensions || 'Loading...' }})</span>
<span v-else>{{ truncateContent(item.content) }}</span> <span v-else>{{ truncateContent(item.content) }}</span>
@ -225,13 +225,8 @@ const truncateContent = (content: string): string => {
return content.length > maxChars ? content.slice(0, maxChars - 3) + '...' : content; return content.length > maxChars ? content.slice(0, maxChars - 3) + '...' : content;
}; };
const isUrl = (str: string): boolean => { const hasFavicon = (str: string): boolean => {
try { return str.trim() !== '';
new URL(str);
return true;
} catch {
return false;
}
}; };
const isYoutubeWatchUrl = (url: string): boolean => { const isYoutubeWatchUrl = (url: string): boolean => {