Skip to content

Commit

Permalink
feat: improve ready state handling
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pokorný <[email protected]>
  • Loading branch information
JanPokorny committed Jan 7, 2025
1 parent ec2d57a commit 1c9c8bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ const ALLOWED_ORIGINS = (import.meta.env.VITE_ALLOWED_FRAME_ANCESTORS ?? '').spl
app.kernel._worker.addEventListener('message', (event: MessageEvent) => {
const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
switch (data.type) {
case 'bee:ready':
ALLOWED_ORIGINS.forEach((origin: string) => parent.postMessage({ type: 'bee:ready' }, origin))
return;

case 'bee:request':
ALLOWED_ORIGINS.forEach((origin: string) => parent.postMessage(data, origin));
return;

default:
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/python/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def fix_markdown(body):


async def run():
js.postMessage(json.dumps({ "type": "bee:ready" }))
try:
code = pathlib.Path("app.py").read_text()
if st.session_state.get("_bee_last_code") != code:
Expand Down

0 comments on commit 1c9c8bd

Please sign in to comment.