[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Use pathname for navigation

Kasper (Oct 8, 2024, 11:18 PM +0200) 44ac3244 c6c5d084

+18 -18
+1
src/components/CheckForUpdates.svelte
··· 48 48 } 49 49 }} 50 50 > 51 + <!-- svelte-ignore a11y-autofocus --> 51 52 <div class="w-md max-w-xl text-sm outline-none" autofocus tabindex="-1"> 52 53 <p class="pb-3"> 53 54 Ferrum {latest_update.channel.version} is available. You are currently on {latest_update.app_version}
+6 -6
src/components/SidebarItems.svelte
··· 31 31 import * as dragGhost from './DragGhost.svelte' 32 32 import { ipc_renderer } from '@/lib/window' 33 33 import { check_shortcut } from '@/lib/helpers' 34 - import { navigate, url } from '@/lib/router' 34 + import { navigate, url_pathname } from '@/lib/router' 35 35 import { current_playlist_id } from './TrackList.svelte' 36 36 37 37 export let show = true ··· 87 87 88 88 export function handle_key(e: KeyboardEvent) { 89 89 const index = children.findIndex((child) => { 90 - return child.path === $url.pathname 90 + return child.path === $url_pathname 91 91 }) 92 92 if (index < 0) { 93 93 return ··· 115 115 } 116 116 e.preventDefault() 117 117 } 118 - $: if (children.find((child) => child.path === $url.pathname)) { 118 + $: if (children.find((child) => child.path === $url_pathname)) { 119 119 const item_handle = getContext<Writable<SidebarItemHandle | null>>('itemHandle') 120 120 item_handle.set({ handleKey: handle_key }) 121 121 } ··· 147 147 tabindex="-1" 148 148 class="item rounded-r-[5px]" 149 149 style:padding-left={14 * level + 'px'} 150 - class:active={child_list.path === $url.pathname} 150 + class:active={child_list.path === $url_pathname} 151 151 draggable="true" 152 152 on:dragstart={(e) => on_drag_start(e, child_list)} 153 153 class:show={$shown_folders.includes(child_list.id)} ··· 244 244 style:padding-left={14 * level + 'px'} 245 245 draggable="true" 246 246 on:dragstart={(e) => on_drag_start(e, child_list)} 247 - class:active={child_list.path === $url.pathname} 247 + class:active={child_list.path === $url_pathname} 248 248 on:mousedown={() => navigate(child_list.path)} 249 249 class:droppable={drag_track_onto_index === i} 250 250 class:droppable-above={drag_playlist_onto_index === i && drop_above} ··· 308 308 class="item rounded-r-[5px]" 309 309 style:padding-left={14 * level + 'px'} 310 310 on:mousedown={() => navigate(child_list.path)} 311 - class:active={child_list.path === $url.pathname} 311 + class:active={child_list.path === $url_pathname} 312 312 > 313 313 <div class="arrow" /> 314 314 <div class="text">
+4 -4
src/lib/Route.svelte
··· 1 1 <script lang="ts"> 2 2 import type { SvelteComponent } from 'svelte' 3 - import { url } from './router' 3 + import { url_pathname } from './router' 4 4 5 5 export let route: string 6 6 $: route_segments = route.split('/') 7 - $: params = parse($url.pathname) 7 + $: params = parse($url_pathname) 8 8 9 9 export let component: typeof SvelteComponent<Record<string, unknown>, Record<string, unknown>> 10 10 11 - function parse(path: string) { 11 + function parse(pathname: string) { 12 12 const params: Record<string, string> = {} 13 - const path_segments = path.split('/') 13 + const path_segments = pathname.split('/') 14 14 if (route_segments.length !== path_segments.length) { 15 15 return null 16 16 }
+7 -8
src/lib/router.ts
··· 1 1 import { writable } from 'svelte/store' 2 2 3 - export const url = writable(new URL(window.location.href)) 3 + export const url_pathname = writable(window.location.pathname) 4 4 5 - export function navigate(to_url: string, options: { replace?: boolean } = {}) { 6 - const new_url = new URL(to_url, window.location.href) 7 - if (new_url.href !== window.location.href) { 5 + export function navigate(to_pathname: string, options: { replace?: boolean } = {}) { 6 + if (to_pathname !== window.location.pathname + window.location.search) { 8 7 if (options.replace) { 9 - window.history.replaceState({}, '', new_url) 8 + window.history.replaceState({}, '', to_pathname) 10 9 } else { 11 - window.history.pushState({}, '', new_url) 10 + window.history.pushState({}, '', to_pathname) 12 11 } 13 - url.set(new_url) 12 + url_pathname.set(to_pathname) 14 13 } 15 14 } 16 15 ··· 35 34 window.history.forward() 36 35 } 37 36 window.addEventListener('popstate', () => { 38 - url.set(new URL(window.location.href)) 37 + url_pathname.set(window.location.pathname) 39 38 })