Skip to content

Commit 4994bc2

Browse files
TrackInfo: Improve error handling & update to Svelte 5
1 parent 2893a6e commit 4994bc2

File tree

6 files changed

+198
-219
lines changed

6 files changed

+198
-219
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Next
44
- Add genre autocomplete
55
- Make macOS media key permission request non-intrusive
6-
- Improve crashing behaviour
6+
- Improve error and crashing behaviour
77

88
## 0.19.9 - 2025 Jul 4
99
- Fix column size not updating when resizing window

src-native/tracks/cover.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
use super::{Tag, id_to_track};
2-
use crate::data_js::get_data;
1+
use super::Tag;
32
use anyhow::{Context, Result, anyhow, bail};
43
use fast_image_resize::images::Image;
54
use fast_image_resize::{IntoImageView, Resizer};
65
use image::codecs::jpeg::JpegEncoder;
76
use image::codecs::png::PngEncoder;
87
use image::{ImageEncoder, ImageFormat, ImageReader};
98
use lazy_static::lazy_static;
10-
use napi::Env;
11-
use napi::bindgen_prelude::{Buffer, PromiseRaw};
9+
use napi::bindgen_prelude::Buffer;
1210
use redb::{Database, TableDefinition};
1311
use std::fs;
1412
use std::io::{BufWriter, Cursor};

src-native/tracks/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ pub fn import_file(path: String, now: MsSinceUnixEpoch, env: Env) -> Result<()>
162162
pub fn load_tags(track_id: String, env: Env) -> Result<()> {
163163
let data: &mut Data = get_data(&env);
164164
data.current_tag = None;
165-
let track = id_to_track(&env, &track_id)?;
165+
let track = id_to_track(&env, &track_id).context("Could not load tags")?;
166166

167167
let path = data.paths.tracks_dir.join(&track.file);
168-
let tag = Tag::read_from_path(&path)?;
168+
let tag = Tag::read_from_path(&path).context("Could not load tags")?;
169169
data.current_tag = Some(tag);
170170
Ok(())
171171
}

src/App.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Player from './components/Player.svelte'
66
import Sidebar from './components/Sidebar.svelte'
77
import Queue from './components/Queue.svelte'
8-
import TrackInfo, { current_list } from './components/TrackInfo.svelte'
8+
import TrackInfo, { track_info_state } from './components/TrackInfo.svelte'
99
import PlaylistInfoModal from './components/PlaylistInfo.svelte'
1010
import { queue_visible } from './lib/queue'
1111
import { ipc_listen, ipc_renderer } from '@/lib/window'
@@ -217,6 +217,7 @@
217217
<div class="meat">
218218
<Sidebar />
219219
<div class="flex size-full min-w-0 flex-col">
220+
ID{track_info_state.instance?.id}
220221
<Route route="/playlist/:playlist_id" component={TrackList} />
221222
<Route route="/artists" component={ArtistList} />
222223
{#if media_keys_result}
@@ -294,8 +295,8 @@
294295
</main>
295296

296297
<QuickNav />
297-
{#if $current_list}
298-
<TrackInfo />
298+
{#if track_info_state.instance}
299+
<TrackInfo bind:instance={track_info_state.instance} />
299300
{/if}
300301
{#if playlist_info}
301302
<PlaylistInfoModal info={playlist_info} cancel={() => (playlist_info = null)} />

0 commit comments

Comments
 (0)