diff --git a/src/pages/configurator/input/_applet.astro b/src/pages/configurator/input/_applet.astro index 7b3e42a..6ff5b94 100644 --- a/src/pages/configurator/input/_applet.astro +++ b/src/pages/configurator/input/_applet.astro @@ -6,6 +6,7 @@

+ My device diff --git a/src/pages/input/native-fs/_applet.astro b/src/pages/input/native-fs/_applet.astro index f05670f..f56bc98 100644 --- a/src/pages/input/native-fs/_applet.astro +++ b/src/pages/input/native-fs/_applet.astro @@ -92,8 +92,7 @@ // ACTIONS //////////////////////////////////////////// const consult = async (fileUriOrScheme: string) => { - const isSupported = !!(globalThis as any).showDirectoryPicker; - if (!isSupported) { + if (!isSupported()) { return { supported: false, reason: "File System Access API is not supported" }; } @@ -109,13 +108,19 @@ }; const list = async (cachedTracks: Track[] = []) => { + if (!isSupported()) return cachedTracks; + + // Continue if supported const handles = await fetchHandlesList(); + + // Recursive listing of all tracks of available handles const processed: Track[][] = await Promise.all( handles.map(({ id, handle }) => { return recursiveList(handle, id, []); }), ); + // Group tracks by handle id & index by track uri const cache = cachedTracks.reduce( (acc: Record>, track: Track) => { const handleId = trackHandleId(track); @@ -126,6 +131,9 @@ {}, ); + // Replace indexes in groups of which we have the handle. + // Keeping around tracks with handles we don't have access to, + // and removing tracks that are no longer available (for handles we do have access to). const groups = processed.flat(1).reduce( (acc, track) => { const handleId = trackHandleId(track); @@ -138,6 +146,7 @@ }, cache), ); + // Transform in track list and sort by uri const data = Object.values(groups) .map((tracks) => Object.values(tracks)) .flat(1) @@ -153,8 +162,7 @@ }; const resolve = async (fileUri: string) => { - const isSupported = !!(globalThis as any).showDirectoryPicker; - if (!isSupported) return undefined; + if (!isSupported()) return undefined; const uri = URI.parse(fileUri); if (uri.scheme !== SCHEME) return undefined; @@ -229,6 +237,10 @@ }); } + function isSupported() { + return !!(globalThis as any).showDirectoryPicker; + } + function trackCid(track: Track): string | undefined { const a = URI.parse(track.uri); const cid = a.query ? QS.parse(a.query).cid || undefined : undefined; diff --git a/src/scripts/themes/webamp/index.ts b/src/scripts/themes/webamp/index.ts index 83aba45..3bd3f06 100644 --- a/src/scripts/themes/webamp/index.ts +++ b/src/scripts/themes/webamp/index.ts @@ -1,7 +1,6 @@ import Webamp from "webamp"; -// import "98.css"; -import type { Output, Track } from "@applets/core/types.d.ts"; +import type { Track } from "@applets/core/types.d.ts"; import { applet } from "../../theme.ts"; ////////////////////////////////////////////