+57
index.html
+57
index.html
···
362
362
},
363
363
}));
364
364
365
+
Alpine.data('repoSize', () => ({
366
+
lading: false,
367
+
error: null,
368
+
size: null,
369
+
370
+
async loadRepoForSize(did, pds) {
371
+
this.loading = true;
372
+
373
+
if (!did || !pds) {
374
+
this.loading = false;
375
+
return;
376
+
}
377
+
const query = window.SimpleQuery(pds);
378
+
try {
379
+
const res = await query('com.atproto.sync.getRepo', {
380
+
params: { did },
381
+
as: 'blob',
382
+
});
383
+
let bytes = res.size;
384
+
let mbs = bytes / Math.pow(2, 20);
385
+
this.size = mbs.toFixed(1);
386
+
} catch (e) {
387
+
if (window.isXrpcErr(e)) {
388
+
this.error = e.error;
389
+
} else {
390
+
this.error = 'failed (see console)';
391
+
console.error(e);
392
+
}
393
+
}
394
+
this.loading = false;
395
+
},
396
+
}));
397
+
365
398
Alpine.data('relayCheckRepo', (did, relay) => ({
366
399
loading: false,
367
400
error: null,
···
725
758
@click.prevent="goto(pds)"
726
759
x-text="pds"
727
760
></a>
761
+
</td>
762
+
</tr>
763
+
<tr>
764
+
<td class="text-sm">
765
+
Size:
766
+
<span x-data="repoSize">
767
+
<template x-if="loading">
768
+
<em>loading…</em>
769
+
</template>
770
+
<template x-if="error">
771
+
<span class="text-xs text-warning" x-text="error"></span>
772
+
</template>
773
+
<template x-if="size">
774
+
<code>
775
+
<span x-text="size"></span> MiB
776
+
</code>
777
+
</template>
778
+
<template x-if="!size && !error && !loading">
779
+
<button
780
+
class="btn btn-xs btn-soft btn-primary"
781
+
@click.prevent="loadRepoForSize(did, pds)"
782
+
>load</button>
783
+
</template>
784
+
</span>
728
785
</td>
729
786
</tr>
730
787
</tbody>