From ca925f4b268631d92953aa57d2626ed4278eb906 Mon Sep 17 00:00:00 2001 From: Rizky Date: Thu, 19 Oct 2023 04:28:10 +0000 Subject: [PATCH] fix --- app/srv/ws/handler.ts | 17 -------------- app/web/src/render/live/live.tsx | 4 ---- app/web/src/render/live/logic/ws-sync.ts | 28 ------------------------ 3 files changed, 49 deletions(-) delete mode 100644 app/web/src/render/live/logic/ws-sync.ts diff --git a/app/srv/ws/handler.ts b/app/srv/ws/handler.ts index 06815e3d..87616645 100644 --- a/app/srv/ws/handler.ts +++ b/app/srv/ws/handler.ts @@ -24,23 +24,6 @@ const site = { const brotli = await brotliPromise; export const wsHandler: Record> = { - "/live": { - async open(ws) { - ws.send( - brotli.compress( - Buffer.from( - JSON.stringify( - await db.page.findFirst({ - where: { id: "324dde34-1e01-46ff-929c-124e5e01f585" }, - }) - ) - ), - { quality: 11 } - ) - ); - }, - message(ws, message) {}, - }, "/edit": { open(ws) { eg.edit.ws.set(ws, { diff --git a/app/web/src/render/live/live.tsx b/app/web/src/render/live/live.tsx index 31c6b72a..e459169c 100644 --- a/app/web/src/render/live/live.tsx +++ b/app/web/src/render/live/live.tsx @@ -5,7 +5,6 @@ import { LPage } from "./elements/l-page"; import { LiveGlobal, Loader } from "./logic/global"; import { initLive, w } from "./logic/init"; import { preload, routeLive } from "./logic/route"; -import { liveSyncWS } from "./logic/ws-sync"; export const Live: FC<{ domain_or_siteid: string; @@ -57,9 +56,6 @@ export const Live: FC<{ }, [p.site.responsive]); if (p.status === "init") { - if (liveSync) { - liveSyncWS(p); - } initLive(p, domain_or_siteid); } diff --git a/app/web/src/render/live/logic/ws-sync.ts b/app/web/src/render/live/logic/ws-sync.ts deleted file mode 100644 index e127dcf4..00000000 --- a/app/web/src/render/live/logic/ws-sync.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { PG } from "./global"; - -export const liveSyncWS = async (p: PG) => { - if (!p.liveSync.init) { - p.liveSync.init = true; - - if (!p.liveSync.decompress) { - const brotliPromise = (await import("brotli-dec-wasm")).default; - p.liveSync.decompress = (await brotliPromise).decompress; - } - const decoder = new TextDecoder(); - const url = new URL(location.href); - url.pathname = "/live"; - url.protocol = url.protocol === "http:" ? "ws:" : "wss:"; - - const ws = new WebSocket(url); - p.liveSync.ws = ws; - ws.onmessage = async (e) => { - const decompress = p.liveSync.decompress; - if (decompress) { - const raw = e.data as Blob; - const extracted = decompress(new Uint8Array(await raw.arrayBuffer())); - const json = JSON.parse(decoder.decode(extracted)); - console.log(json); - } - }; - } -};