summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/users.svelte.js
blob: 617084f91dda71c0b7ddeb39ed697676aace5796 (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 Users {
  all = $state();

  static boot(users) {
    const all = new SvelteMap(users.map((user) => [user.id, user]));
    return new Users({ all });
  }

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

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