build-container / build (push) Successful in 22m24s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
18 lines
1.2 KiB
JavaScript
18 lines
1.2 KiB
JavaScript
'use strict';
|
|
// Files shared into NE Hub from other apps (the manifest's share target; sw.js keeps them): choose a Seafile folder, then upload.
|
|
async function shareCheck() {
|
|
if (!('caches' in window)) return;
|
|
let c, keys;
|
|
try { c = await caches.open('hub-share'); keys = await c.keys(); } catch { return; }
|
|
if (!keys.length) return;
|
|
const clear = async () => { for (const k of await c.keys()) await c.delete(k); };
|
|
if (!allowed('files')) { await clear(); toast('You do not have the Files tab, so shared files were discarded'); return; }
|
|
const files = [];
|
|
for (const k of keys) { const r = await c.match(k); if (r) files.push(new File([await r.blob()], decodeURIComponent(r.headers.get('x-name') || 'file'), { type: r.headers.get('content-type') || '' })); }
|
|
const loc = store.get('office_loc');
|
|
const dst = await chooseFolder('Save ' + (files.length === 1 ? '“' + files[0].name + '”' : files.length + ' shared files') + ' to…', loc ? { repo: loc.repo, repoName: loc.repoName || '', dir: loc.dir } : null, { okLabel: 'Upload here', newFolder: true });
|
|
await clear();
|
|
if (!dst) return toast('Shared files discarded');
|
|
enqueueUploads(dst.repo, dst.dir, files.map(file => ({ file })));
|
|
}
|