This commit is contained in:
Rizky 2023-11-02 14:11:32 +07:00
parent c35452a085
commit 8f2b07872c
3 changed files with 15 additions and 5 deletions

View File

@ -85,7 +85,7 @@ export const SyncActions = {
type: "join"; type: "join";
id: string; id: string;
} }
| { type: "code"; id: string; action: "open" | "close" } | { type: "code"; id: string; name: string; action: "open" | "close" }
) => {}, ) => {},
client: { client: {
info: async (client_ids: string[]) => info: async (client_ids: string[]) =>

View File

@ -4,9 +4,18 @@ import { activity as a } from "../entity/activity";
export const activity: SAction["activity"] = async function ( export const activity: SAction["activity"] = async function (
this: SyncConnection, this: SyncConnection,
name, name,
type, act
id
) { ) {
if (type === "join") a.site.room(id).join({ ws: this.ws }); const me = { ws: this.ws };
if (type === "leave") a.site.room(id).leave({ ws: this.ws }); if (act.type === "join") a.site.room(act.id).join(me);
if (act.type === "code") {
a.site.room(act.id).set(me, (ws, data) => {
if (act.action === "open") {
data.code = { name: act.name };
} else {
delete data.code;
}
return data;
});
}
}; };

View File

@ -11,6 +11,7 @@ export const EdPopCode = () => {
action: p.ui.popup.code.open ? "open" : "close", action: p.ui.popup.code.open ? "open" : "close",
id: p.site.id, id: p.site.id,
type: "code", type: "code",
name: "main",
}); });
}, [p.ui.popup.code.open]); }, [p.ui.popup.code.open]);