// Round nineteen: downloads on Wi-Fi only — a switch the phone needs and the // desktop never did. One guard (network.svelte.js) before every download // the phone can start; streaming is never refused. const fs = require('fs'); const root = process.env.SS_ROOT || 'F:/Coding/SoulStream/'; let p, s; const load = (file) => { p = file; s = fs.readFileSync(root + p, 'utf8'); }; const save = () => fs.writeFileSync(root + p, s); const once = (a) => { const i = s.indexOf(a); if (i < 0) throw new Error('missing in ' + p + ': ' + a.slice(0, 90)); if (s.indexOf(a, i + 1) >= 0) throw new Error('ambiguous in ' + p + ': ' + a.slice(0, 90)); return i; }; const rep = (a, b) => { once(a); s = s.replace(a, () => b); }; fs.copyFileSync('C:/Users/Kyle/AppData/Local/Temp/claude/F--Coding-SoulStream/5488514a-11e8-482a-b0a0-20cb511ee110/scratchpad/network.svelte.js', root + 'src/mobile/network.svelte.js'); load('src/mobile/prefs.svelte.js'); rep(`export const settings = $state({ ambience: true, accent: true, motion: true, glass: false });`, `export const settings = $state({ ambience: true, accent: true, motion: true, glass: false, wifiOnly: false });`); save(); // ── the guards ── load('src/mobile/resolve.svelte.js'); rep(`import { yearOf } from "./catalog.svelte.js";`, `import { yearOf } from "./catalog.svelte.js"; import { downloadsAllowed } from "./network.svelte.js";`); rep(`export async function saveCatalogAlbum(album) {`, `export async function saveCatalogAlbum(album) { if (!downloadsAllowed()) return false;`); rep(`export async function saveSong(artist, title) { if (resolver.active) return false;`, `export async function saveSong(artist, title) { if (resolver.active) return false; if (!downloadsAllowed()) return false;`); save(); load('src/mobile/playlists.svelte.js'); rep(`import { slsk } from "./slsk.svelte.js";`, `import { slsk } from "./slsk.svelte.js"; import { downloadsAllowed } from "./network.svelte.js";`); rep(`export async function runBulk(p, items, mode) { if (bulk.active) return false;`, `export async function runBulk(p, items, mode) { if (bulk.active) return false; if (mode === "download" && !downloadsAllowed()) return false;`); save(); load('src/mobile/HalfSheet.svelte'); rep(` import { art, wantArt } from "./art.svelte.js";`, ` import { art, wantArt } from "./art.svelte.js"; import { downloadsAllowed } from "./network.svelte.js";`); rep(` async function saveStreams(entries) {`, ` async function saveStreams(entries) { if (!downloadsAllowed()) return;`); rep(` async function saveGroup(g) {`, ` async function saveGroup(g) { if (!downloadsAllowed()) return;`); rep(`act(() => api.downloadFile(g.username, f.path, f.size).then(() => note(`, `act(() => { if (!downloadsAllowed()) return; api.downloadFile(g.username, f.path, f.size).then(() => note(`); save(); // the file row's act closes with ")))}" — reshape to a block load('src/mobile/HalfSheet.svelte'); { const a = `act(() => { if (!downloadsAllowed()) return; api.downloadFile(g.username, f.path, f.size).then(() => note(\`Saving “\${titleFromName(f.name)}” from \${g.username}\`)).catch(oops)))}`; once(a); s = s.replace(a, () => `act(() => { if (!downloadsAllowed()) return; api.downloadFile(g.username, f.path, f.size).then(() => note(\`Saving “\${titleFromName(f.name)}” from \${g.username}\`)).catch(oops); }))}`); save(); } load('src/mobile/screens/Browse.svelte'); rep(` import { note } from "../notice.svelte.js";`, ` import { note } from "../notice.svelte.js"; import { downloadsAllowed } from "../network.svelte.js";`); rep(` async function save(d) { const list = d.files.filter(audio); if (!list.length) return;`, ` async function save(d) { const list = d.files.filter(audio); if (!list.length || !downloadsAllowed()) return;`); save(); // ── You: the switch ── load('src/mobile/screens/You.svelte'); rep(`