A downstream fork of Tranquil PDS for use in margin.cafe margin.cafe
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849<script lang="ts"> import { _ } from '../../lib/i18n' import { api, ApiError } from '../../lib/api' import { toast } from '../../lib/toast.svelte' import type { Session } from '../../lib/types/api' import Icon from '../ui/Icon.svelte' let { session }: { session: Session } = $props() let exportLoading = $state(false)
async function handleExportRepo() { exportLoading = true try { const buffer = await api.getRepo(session.accessJwt, session.did) const blob = new Blob([buffer], { type: 'application/vnd.ipld.car' }) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = `${session.handle}-repo.car` document.body.appendChild(a) a.click() document.body.removeChild(a) URL.revokeObjectURL(url) toast.success($_('settings.messages.repoExported')) } catch (e) { toast.error(e instanceof ApiError ? e.message : $_('settings.messages.exportFailed')) } finally { exportLoading = false } }
</script>
<div class="data-page"> <p class="page-intro">{$_('work.dataIntro')}</p> <section class="data-export" aria-labelledby="export-title"> <div class="data-export-heading"><Icon name="download" size={28} /><div><h2 id="export-title">{$_('settings.exportData')}</h2><p>{$_('work.exportDescription')}</p></div></div> <dl class="data-facts"><div><dt>{$_('dashboard.handle')}</dt><dd>@{session.handle}</dd></div><div><dt>{$_('dashboard.did')}</dt><dd><code>{session.did}</code></dd></div></dl> <div class="actions"> <button type="button" onclick={handleExportRepo} disabled={exportLoading}>{exportLoading ? $_('settings.exporting') : $_('settings.downloadRepo')}</button> <a class="text-action" href="/app/repo">{$_('dashboard.navRepo')}<Icon name="arrow" size={16} /></a> </div> </section> <section class="data-portability"> <h2>{$_('work.moveAccount')}</h2> <p>{$_('work.moveDescription')}</p> <a class="text-action" href="/app/migrate">{$_('work.moveHere')}<Icon name="arrow" size={16} /></a> </section></div>