Skip to content

Commit 7a73060

Browse files
authored
[Bugfix]: Preventing error related to missing module instance atom store (#1351)
1 parent 646e59b commit 7a73060

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

frontend/src/framework/AtomStoreMaster.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ export class AtomStoreMaster {
3535
return atomStore;
3636
}
3737

38-
getAtomStoreForModuleInstance(moduleInstanceId: string): AtomStore {
38+
getAtomStoreForModuleInstance(moduleInstanceId: string): AtomStore | null {
3939
const atomStore = this._atomStores.get(moduleInstanceId);
4040
if (!atomStore) {
41-
throw new Error(`No atom store found for module instance with id: ${moduleInstanceId}`);
41+
console.debug(`No atom store found for module instance with id ${moduleInstanceId}`);
42+
return null;
4243
}
4344
return atomStore;
4445
}

frontend/src/framework/internal/components/Content/private-components/ViewWrapper/private-components/viewContent.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ export const ViewContent = React.memo((props: ViewContentProps) => {
3838
ModuleInstanceTopic.HAS_INVALID_PERSISTED_VIEW,
3939
);
4040

41-
const atomStore = workbenchSession.getAtomStoreMaster().getAtomStoreForModuleInstance(props.moduleInstance.getId());
42-
4341
const handleModuleInstanceReload = React.useCallback(
4442
function handleModuleInstanceReload() {
4543
props.moduleInstance.reset();
@@ -127,6 +125,11 @@ export const ViewContent = React.memo((props: ViewContentProps) => {
127125
}
128126
}
129127

128+
const atomStore = workbenchSession.getAtomStoreMaster().getAtomStoreForModuleInstance(props.moduleInstance.getId());
129+
if (!atomStore) {
130+
return null;
131+
}
132+
130133
const View = props.moduleInstance.getViewFC();
131134
return (
132135
<ErrorBoundary moduleInstance={props.moduleInstance}>

frontend/src/framework/internal/components/LeftSettingsPanel/private-components/moduleSettings.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export const ModuleSettings: React.FC<ModuleSettingsProps> = (props) => {
4949

5050
const isSerializable = props.moduleInstance.getModule().canBeSerialized();
5151

52-
const atomStore = workbenchSession!
53-
.getAtomStoreMaster()
54-
.getAtomStoreForModuleInstance(props.moduleInstance.getId());
55-
5652
if (importState !== ImportStatus.Imported || !props.moduleInstance.isInitialized()) {
5753
return null;
5854
}
@@ -105,6 +101,14 @@ export const ModuleSettings: React.FC<ModuleSettingsProps> = (props) => {
105101
);
106102
}
107103

104+
const atomStore = workbenchSession
105+
.getAtomStoreMaster()
106+
.getAtomStoreForModuleInstance(props.moduleInstance.getId());
107+
108+
if (!atomStore) {
109+
return null;
110+
}
111+
108112
return (
109113
<>
110114
{!isSerializable && (

0 commit comments

Comments
 (0)