Skip to content

Commit 9f04507

Browse files
authored
Update contribution state (#9)
* Initial changes * Adding componentState instead of componentModelResult
1 parent db218d1 commit 9f04507

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

dashi/src/actions/handleComponentPropertyChange.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function applyChangeRequests(changeRequests: ChangeRequest[]) {
109109
appStore.getState().contributionStatesRecord;
110110
const contributionStates = contributionStatesRecord[contribPoint];
111111
const contributionState = contributionStates[contribIndex];
112-
const componentModelOld = contributionState.componentModelResult.data;
112+
const componentModelOld = contributionState.componentState;
113113
let componentModel = componentModelOld;
114114
changes.forEach((change) => {
115115
if (componentModel && (!change.kind || change.kind === "Component")) {
@@ -131,10 +131,7 @@ function applyChangeRequests(changeRequests: ChangeRequest[]) {
131131
contribIndex,
132132
{
133133
...contributionState,
134-
componentModelResult: {
135-
...contributionState.componentModelResult,
136-
data: componentModel,
137-
},
134+
componentState: componentModel,
138135
},
139136
),
140137
},

dashi/src/actions/setComponentVisibility.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ export function setComponentVisibility(
2929
panelIndex,
3030
inputValues,
3131
).then((componentModelResult) => {
32+
const componentState = componentModelResult?.data;
3233
updateContributionState(contribPoint, panelIndex, {
3334
componentModelResult,
35+
componentState,
3436
});
3537
});
3638
}

dashi/src/app/Panel.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ function Panel({ panelModel, panelState, onPropertyChange }: PanelProps) {
4040
if (!panelState.visible) {
4141
return null;
4242
}
43+
const componentState = panelState.componentState;
4344
let panelElement: ReactElement | null = null;
4445
const componentModelResult = panelState.componentModelResult;
45-
if (componentModelResult.data) {
46+
if (componentModelResult.data && componentState) {
4647
panelElement = (
47-
<DashiComponent
48-
{...componentModelResult.data}
49-
onPropertyChange={onPropertyChange}
50-
/>
48+
<DashiComponent {...componentState} onPropertyChange={onPropertyChange} />
5149
);
5250
} else if (componentModelResult.error) {
5351
panelElement = (

dashi/src/store/appStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type ContribPoint = string;
1010
export interface ContributionState {
1111
visible?: boolean;
1212
componentModelResult: ApiResult<ComponentModel>;
13+
componentState?: ComponentModel;
1314
}
1415

1516
export interface AppState {

0 commit comments

Comments
 (0)