A music player that connects to your cloud/distributed storage.

fix: theme loader

+15 -15
+5 -6
src/common/themes/utils.js
··· 1 + import { loadURI } from "../loader.js"; 1 2 import * as CID from "../cid.js"; 2 3 3 4 /** ··· 5 6 */ 6 7 7 8 /** 8 - * @param {{ name: string; url: string }} _args 9 + * @param {{ name: string; uri: string }} _args 9 10 * @param {{ fetchHTML: boolean }} options 10 11 */ 11 - export async function themeFromUrl({ name, url }, { fetchHTML }) { 12 - const html = fetchHTML 13 - ? await fetch(url).then((res) => res.text()) 14 - : undefined; 12 + export async function themeFromURI({ name, uri }, { fetchHTML }) { 13 + const html = fetchHTML ? await loadURI(uri) : undefined; 15 14 const cid = html 16 15 ? await CID.create(0x55, new TextEncoder().encode(html)) 17 16 : undefined; ··· 26 25 html, 27 26 name, 28 27 updatedAt: timestamp, 29 - url, 28 + uri, 30 29 }; 31 30 32 31 return theme;
+10 -9
src/themes/index.js
··· 10 10 import * as CID from "@common/cid.js"; 11 11 import foundation from "@common/facets/foundation.js"; 12 12 import { effect, signal } from "@common/signal.js"; 13 - import { themeFromUrl } from "@common/themes/utils.js"; 13 + import { themeFromURI } from "@common/themes/utils.js"; 14 + import { loadURI } from "@common/loader.js"; 14 15 15 16 /** 16 17 * @import {Theme} from "@definitions/types.d.ts" ··· 30 31 const rel = target.getAttribute("rel"); 31 32 if (!rel) return; 32 33 33 - const url = target.closest("li")?.getAttribute("data-url"); 34 - if (!url) return; 34 + const uri = target.closest("li")?.getAttribute("data-uri"); 35 + if (!uri) return; 35 36 36 37 const name = target.closest("li")?.getAttribute("data-name"); 37 38 if (!name) return; 38 39 39 40 switch (rel) { 40 41 case "fork": { 41 - const theme = await themeFromUrl({ name, url }, { fetchHTML: true }); 42 + const theme = await themeFromURI({ name, uri }, { fetchHTML: true }); 42 43 editTheme(theme); 43 44 document.querySelector("#build")?.scrollIntoView(); 44 45 break; 45 46 } 46 47 case "save": { 47 - const theme = await themeFromUrl({ name, url }, { fetchHTML: false }); 48 + const theme = await themeFromURI({ name, uri }, { fetchHTML: false }); 48 49 const out = foundation.orchestrator.output(); 49 50 50 51 out.themes.save([ ··· 98 99 </button> 99 100 </div> 100 101 <div class="list-description"> 101 - ${c.url && !c.html 102 + ${c.uri && !c.html 102 103 ? html` 103 104 <span class="with-icon"> 104 105 <i class="ph-fill ph-binoculars"></i> 105 106 <span>Tracking the original <a href="${c 106 - .url}">URL</a></span> 107 + .uri}">URI</a></span> 107 108 </span> 108 109 ` 109 110 : html` ··· 256 257 if (!nameEl) return; 257 258 258 259 // Make sure HTML is loaded 259 - if (!theme.html && theme.url) { 260 - const html = await fetch(theme.url).then((res) => res.text()); 260 + if (!theme.html && theme.uri) { 261 + const html = await loadURI(theme.uri); 261 262 const cid = await CID.create(0x55, new TextEncoder().encode(html)); 262 263 263 264 theme.html = html;