fix broadcast

This commit is contained in:
Rizky 2023-10-26 11:55:31 +07:00
parent 883aca22c6
commit d84feffc21
9 changed files with 25 additions and 19 deletions

View File

@ -6,7 +6,7 @@ import {
} from "../../../web/src/render/ed/logic/ed-global";
import { IItem } from "../../../web/src/utils/types/item";
import { site_group } from "./actions/site_group";
import { Activity } from "./entity/actstore";
import { Activity } from "./type";
/*
WARNING:

View File

@ -1,7 +1,7 @@
import { validate } from "uuid";
import { SAction } from "../actions";
import { Activity, actstore, broadcastActivity } from "../entity/actstore";
import { SyncConnection } from "../type";
import { actstore, broadcastActivity } from "../entity/actstore";
import { Activity, SyncConnection } from "../type";
export const activity: SAction["activity"] = async function (
this: SyncConnection,

View File

@ -6,8 +6,8 @@ import { snapshot } from "../entity/snapshot";
import { user } from "../entity/user";
import { gzipAsync } from "../entity/zlib";
import { sendWS } from "../sync-handler";
import { SyncConnection, SyncType } from "../type";
import { Activity, actstore, broadcastActivity } from "../entity/actstore";
import { Activity, SyncConnection, SyncType } from "../type";
import { actstore, broadcastActivity } from "../entity/actstore";
export const page_load: SAction["page"]["load"] = async function (
this: SyncConnection,
@ -34,12 +34,6 @@ export const page_load: SAction["page"]["load"] = async function (
load.root[this.client_id] = Activity.Open;
}
}
broadcastActivity(
{
page_id: id,
},
[this.client_id]
);
const createUndoManager = async (root: Y.Map<any>) => {
const um = new Y.UndoManager(root, {
@ -112,6 +106,10 @@ export const page_load: SAction["page"]["load"] = async function (
page_id: page.id,
});
broadcastActivity({
page_id: id,
});
return {
id: id,
url: page.url,
@ -142,6 +140,10 @@ export const page_load: SAction["page"]["load"] = async function (
page_id: snap.id,
});
broadcastActivity({
page_id: id,
});
return {
id: id,
url: snap.url,
@ -157,6 +159,10 @@ export const page_load: SAction["page"]["load"] = async function (
page_id: snap.id,
});
broadcastActivity({
page_id: id,
});
return {
id: snap.id,
url: snap.url,

View File

@ -1,7 +1,7 @@
import { ServerWebSocket } from "bun";
import { WSData } from "../../../../../pkgs/core/server/create";
import { sendWS } from "../sync-handler";
import { SyncType } from "../type";
import { Activity, SyncType } from "../type";
import { conns } from "./conn";
import { user } from "./user";
@ -10,10 +10,6 @@ type COMP_ID = string;
type ITEM_ID = string;
type CLIENT_ID = string;
export enum Activity {
Open,
Null,
}
export type ActivityKind = "root" | "js" | "css" | "html" | "text";
export type ActivityList = Record<
ITEM_ID,

View File

@ -3,6 +3,11 @@ import { UserConf } from "./entity/user";
import { WSData } from "../../../../pkgs/core/server/create";
import { user } from "../../../db/db";
export enum Activity {
Open,
Null,
}
export enum SyncType {
ClientID,
UserID,

View File

@ -3,7 +3,7 @@ import { EdMonaco } from "./monaco/monaco";
import { EDGlobal, active } from "../../logic/ed-global";
import { compress } from "wasm-gzip";
import { jscript } from "../../../../utils/script/jscript";
import { Activity } from "../../../../../../srv/ws/sync/entity/actstore";
import { Activity } from "../../../../../../srv/ws/sync/type";
export const EdScriptSite = () => {
const p = useGlobal(EDGlobal, "EDITOR");

View File

@ -1,7 +1,7 @@
import { useGlobal } from "web-utils";
import { TopBtn } from "../top-btn";
import { EDGlobal, active } from "../../../logic/ed-global";
import { Activity } from "../../../../../../../srv/ws/sync/entity/actstore";
import { Activity } from "../../../../../../../srv/ws/sync/type";
export const EdSiteJS = () => {
const p = useGlobal(EDGlobal, "EDITOR");

View File

@ -153,7 +153,6 @@ const connect = (
const ws = new WebSocket(url.toString());
ws.onopen = () => {
console.clear();
sendWs(ws, { type: SyncType.UserID, user_id, site_id, page_id });
conf.ws = ws;
event.connected();

BIN
bun.lockb

Binary file not shown.