diff --git a/CHANGELOG.md b/CHANGELOG.md index 59ab324..d1c2390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Disable components on `room.phase` changed to non-`connected`. + ## 0.3.13 - Added a lite version of Fastboard where `@netless/app-slide` is not registered.\ diff --git a/packages/fastboard-core/src/impl/FastboardApp.ts b/packages/fastboard-core/src/impl/FastboardApp.ts index 84272d4..9f24f66 100644 --- a/packages/fastboard-core/src/impl/FastboardApp.ts +++ b/packages/fastboard-core/src/impl/FastboardApp.ts @@ -311,6 +311,13 @@ export class FastboardApp = any> extends }) ); + /** + * Returns `writable && phase === "connected"`. + */ + get canOperate(): boolean { + return this.room.isWritable && this.room.phase === "connected"; + } + /** * Undo a step on main view. */ diff --git a/packages/fastboard-ui/src/components/PageControl/PageControl.svelte b/packages/fastboard-ui/src/components/PageControl/PageControl.svelte index b9e2ea1..1a950ce 100644 --- a/packages/fastboard-ui/src/components/PageControl/PageControl.svelte +++ b/packages/fastboard-ui/src/components/PageControl/PageControl.svelte @@ -28,7 +28,8 @@ const name = "fastboard-page-control"; $: writable = app?.writable; - $: disabled = !$writable; + $: phase = app?.phase; + $: disabled = !($writable && $phase === "connected"); $: t = i18n[language]; let type: IconType; diff --git a/packages/fastboard-ui/src/components/RedoUndo/RedoUndo.svelte b/packages/fastboard-ui/src/components/RedoUndo/RedoUndo.svelte index 4a283eb..7bf3802 100644 --- a/packages/fastboard-ui/src/components/RedoUndo/RedoUndo.svelte +++ b/packages/fastboard-ui/src/components/RedoUndo/RedoUndo.svelte @@ -26,7 +26,8 @@ const name = "fastboard-redo-undo"; $: writable = app?.writable; - $: disabled = !$writable; + $: phase = app?.phase; + $: disabled = !($writable && $phase === "connected"); $: t = i18n[language]; let type: IconType; diff --git a/packages/fastboard-ui/src/components/Toolbar/Toolbar.svelte b/packages/fastboard-ui/src/components/Toolbar/Toolbar.svelte index f486ccc..e13a9d0 100644 --- a/packages/fastboard-ui/src/components/Toolbar/Toolbar.svelte +++ b/packages/fastboard-ui/src/components/Toolbar/Toolbar.svelte @@ -16,7 +16,8 @@ const extra_height = (32 + 4 + 4) * 2; $: writable = app?.writable; - $: disabled = !$writable; + $: phase = app?.phase; + $: disabled = !($writable && $phase === "connected"); let collapsed = false; let container_height = svelte_writable(0); diff --git a/packages/fastboard-ui/src/components/ZoomControl/ZoomControl.svelte b/packages/fastboard-ui/src/components/ZoomControl/ZoomControl.svelte index a98359c..7f3a294 100644 --- a/packages/fastboard-ui/src/components/ZoomControl/ZoomControl.svelte +++ b/packages/fastboard-ui/src/components/ZoomControl/ZoomControl.svelte @@ -49,7 +49,8 @@ const name = "fastboard-zoom-control"; $: writable = app?.writable; - $: disabled = !$writable; + $: phase = app?.phase; + $: disabled = !($writable && $phase === "connected"); $: t = i18n[language]; let type: IconType; diff --git a/packages/fastboard-ui/test/App.svelte b/packages/fastboard-ui/test/App.svelte index ae162ee..a8e1643 100644 --- a/packages/fastboard-ui/test/App.svelte +++ b/packages/fastboard-ui/test/App.svelte @@ -1,8 +1,9 @@