Skip to content

Commit

Permalink
Throw edit mode error only when a realm exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed May 31, 2024
1 parent c7fb228 commit de951d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-numbers-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chialab/quantum": patch
---

Throw edit mode error only when a realm exists.
4 changes: 2 additions & 2 deletions src/Realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ export function attachRealm(node) {
* @returns {Realm|null} The realm instance or null.
*/
export function getRealm(node, editMode = false) {
const realm = node[REALM_SYMBOL] ?? null;
if (opened) {
if (editMode) {
if (editMode && realm) {
throw new Error('Cannot get realm in edit mode when all realms are open');
}
return null;
}
const realm = node[REALM_SYMBOL] ?? null;
if (realm && !realm.open) {
return realm;
}
Expand Down

0 comments on commit de951d0

Please sign in to comment.