summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/logins.svelte.js
blob: d19068db18891389f3c5b848ee654b36ca367473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { SvelteMap } from 'svelte/reactivity';

export class Logins {
  all = $state();

  static boot(logins) {
    const all = new SvelteMap(logins.map((login) => [login.id, login]));
    return new Logins({ all });
  }

  constructor({ all }) {
    this.all = all;
  }

  add({ id, name }) {
    this.all.set(id, { id, name });
  }
}