aboutsummaryrefslogtreecommitdiff
path: root/client-web/source/room_watches.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-01-27 20:08:18 +0100
committermetamuffin <metamuffin@disroot.org>2024-01-27 20:08:18 +0100
commitc8063785853e516280cd68e9d8e9ae79b2081989 (patch)
treeabf27a18afaae287563fee440e57741a59af3714 /client-web/source/room_watches.ts
parent91259369b2b87eb647e9743c874d7e58894149c1 (diff)
downloadkeks-meet-c8063785853e516280cd68e9d8e9ae79b2081989.tar
keks-meet-c8063785853e516280cd68e9d8e9ae79b2081989.tar.bz2
keks-meet-c8063785853e516280cd68e9d8e9ae79b2081989.tar.zst
cache room hashes, bump versionv1.0.1
Diffstat (limited to 'client-web/source/room_watches.ts')
-rw-r--r--client-web/source/room_watches.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/client-web/source/room_watches.ts b/client-web/source/room_watches.ts
index 2e8d2f9..fd7d54b 100644
--- a/client-web/source/room_watches.ts
+++ b/client-web/source/room_watches.ts
@@ -6,7 +6,7 @@
/// <reference lib="dom" />
import { array_swap, e } from "./helper.ts";
import { PREFS, change_pref } from "./preferences/mod.ts";
-import { crypto_hash } from "./protocol/crypto.ts";
+import { room_hash } from "./protocol/crypto.ts";
import { SignalingConnection } from "./protocol/mod.ts";
interface Watch {
@@ -22,9 +22,15 @@ export function ui_room_watches(conn: SignalingConnection): HTMLElement {
let watches: Watch[] = []
const update_watches = () => (conn.send_control({ watch_rooms: watches.map(w => w.hash) }), update_listing());
- const add_watch = async (secret: string) => watches.push({ name: secret.split("#")[0], secret, hash: await crypto_hash(secret), user_count: 0 })
- const save_watches = () => change_pref("room_watches", JSON.stringify(watches.map(w => w.secret)))
- const load_watches = async () => { for (const secret of JSON.parse(PREFS.room_watches)) { await add_watch(secret) } update_watches() }
+ const add_watch = async (secret: string, hash?: string) => watches.push({ name: secret.split("#")[0], secret, hash: hash ?? await room_hash(secret), user_count: 0 })
+ const save_watches = () => change_pref("room_watches", JSON.stringify(watches.map(w => [w.secret, w.hash])))
+ const load_watches = async () => {
+ for (const stuff of JSON.parse(PREFS.room_watches)) {
+ if (typeof stuff == "string") await add_watch(stuff) // old format
+ else await add_watch(stuff[0], stuff[1])
+ }
+ update_watches()
+ }
conn.control_handler.add_listener(packet => {
if (packet.room_info) {