Skip to content

Commit

Permalink
Fix artwork refreshing when adding artwork
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Sep 25, 2024
1 parent e305dca commit fcabd71
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/components/Cover.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
import { join_paths } from '@/lib/window'
export let track: Track
$: src =
'trackimg:?path=' +
encodeURIComponent(join_paths(paths.tracksDir, track.file)) +
'&cache_db_path=' +
encodeURIComponent(paths.cacheDb) +
'&date_modified=' +
encodeURIComponent(track.dateModified)
let success: boolean | null = null
let failed_src: string | null = null
let loaded = false
</script>

{#if success === false}
{#if src === failed_src && failed_src !== null}
<svg class="cover" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path
d="M23 0l-15.996 3.585v13.04c-2.979-.589-6.004 1.671-6.004 4.154 0 2.137 1.671 3.221 3.485 3.221 2.155 0 4.512-1.528 4.515-4.638v-10.9l12-2.459v8.624c-2.975-.587-6 1.664-6 4.141 0 2.143 1.715 3.232 3.521 3.232 2.14 0 4.476-1.526 4.479-4.636v-17.364z"
Expand All @@ -17,18 +25,15 @@
{:else}
<img
class="cover poinraer-events-none"
class:invisible={success === null}
src="trackimg:?path={encodeURIComponent(
join_paths(paths.tracksDir, track.file),
)}&cache_db_path={encodeURIComponent(paths.cacheDb)}&date_modified={encodeURIComponent(
track.dateModified,
)}"
class:invisible={!loaded}
{src}
alt=""
on:load={() => {
success = true
loaded = true
failed_src = null
}}
on:error={() => {
success = false
failed_src = src
}}
/>
{/if}
Expand All @@ -41,8 +46,6 @@
min-height: 18px
margin: 3px 0px
pointer-events: none
.invisible
opacity: 0
img
object-fit: contain
svg
Expand Down

0 comments on commit fcabd71

Please sign in to comment.