staging-tester / ocean-landing-serve / src/ lib/ live/ remember.ts

import { account } from './account.svelte.js';
import { writeBoot } from './boot.js';
import { identity } from './identity.svelte.js';
import { org } from './org.svelte.js';
import { privateRepos, profile } from './profile.svelte.js';

const plain = <T>(value: T): T => JSON.parse(JSON.stringify(value));

// Saves what the app now shows as the copy the next boot paints from, so a change survives a reload instead of
// reverting until the network answers.
export function remember() {
	if (!identity.me) return;
	writeBoot({ me: plain(identity.me), org: plain(org), profile: plain(profile), account: plain(account), privateRepos: [...privateRepos.names] });
}