Skip to content

Commit 9138cf2

Browse files
committed
renamings after improved typing
1 parent 4a8d29d commit 9138cf2

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

dashi/src/actions/handleComponentPropertyChange.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import appStore, { ContribPoint } from "../store/appStore";
22
import { PropertyChangeEvent } from "../model/component";
33
import { CallbackCallRequest, CallbackCallResult } from "../model/callback";
44
import fetchApiResult from "../utils/fetchApiResult";
5-
import { fetchCallbackOutputs } from "../api";
5+
import { fetchCallbackCallResults } from "../api";
66

77
export default function handleComponentPropertyChange(
88
contribPoint: ContribPoint,
@@ -54,7 +54,7 @@ export default function handleComponentPropertyChange(
5454
});
5555
console.debug("callRequests", callRequests);
5656
if (callRequests.length) {
57-
fetchApiResult(fetchCallbackOutputs, callRequests).then(
57+
fetchApiResult(fetchCallbackCallResults, callRequests).then(
5858
(callResultResult) => {
5959
if (callResultResult.data) {
6060
applyCallbackCallResults(callResultResult.data);

dashi/src/actions/initAppStore.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ export function initAppStore() {
77
const set = appStore.setState;
88

99
set({ extensionsResult: { status: "pending" } });
10-
fetchApiResult(fetchExtensions).then((result) => {
11-
set({ extensionsResult: result });
10+
fetchApiResult(fetchExtensions).then((extensionsResult) => {
11+
set({ extensionsResult });
1212
});
1313

1414
set({ contributionsRecordResult: { status: "pending" } });
15-
fetchApiResult(fetchContributionsRecord).then((result) => {
16-
if (result.data) {
17-
const contributionPointStates: Record<string, ContributionState[]> = {};
18-
Object.getOwnPropertyNames(result.data).forEach((contribPoint) => {
19-
const contributions: Contribution[] = result.data![contribPoint];
20-
contributionPointStates[contribPoint] = contributions.map(() => ({
21-
componentModelResult: {},
22-
}));
23-
});
24-
set({
25-
contributionsRecordResult: result,
26-
contributionStatesRecord: contributionPointStates,
27-
});
15+
fetchApiResult(fetchContributionsRecord).then((contributionsRecordResult) => {
16+
if (contributionsRecordResult.data) {
17+
const contributionStatesRecord: Record<string, ContributionState[]> = {};
18+
Object.getOwnPropertyNames(contributionsRecordResult.data).forEach(
19+
(contribPoint) => {
20+
const contributions: Contribution[] =
21+
contributionsRecordResult.data![contribPoint];
22+
contributionStatesRecord[contribPoint] = contributions.map(() => ({
23+
componentModelResult: {},
24+
}));
25+
},
26+
);
27+
set({ contributionsRecordResult, contributionStatesRecord });
2828
} else {
29-
set({ contributionsRecordResult: result });
29+
set({ contributionsRecordResult });
3030
}
3131
});
3232
}

dashi/src/actions/showPanel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import appStore, { ContribPoint } from "../store/appStore";
22
import fetchApiResult from "../utils/fetchApiResult";
3-
import { fetchLayoutComponent } from "../api";
3+
import { fetchComponentModel } from "../api";
44
import { updateContributionState } from "./updateContributionState";
55

66
export function showPanel(panelIndex: number) {
@@ -22,7 +22,7 @@ export function showPanel(panelIndex: number) {
2222
});
2323
const inputValues = getLayoutInputValues(contribPoint, panelIndex);
2424
fetchApiResult(
25-
fetchLayoutComponent,
25+
fetchComponentModel,
2626
contribPoint,
2727
panelIndex,
2828
inputValues,

dashi/src/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function fetchContributionsRecord(): Promise<
1717
return callApi(`${serverUrl}/dashi/contributions`);
1818
}
1919

20-
export async function fetchLayoutComponent(
20+
export async function fetchComponentModel(
2121
contribPoint: ContribPoint,
2222
contribIndex: number,
2323
inputValues: unknown[],
@@ -28,7 +28,7 @@ export async function fetchLayoutComponent(
2828
});
2929
}
3030

31-
export async function fetchCallbackOutputs(
31+
export async function fetchCallbackCallResults(
3232
callRequests: CallbackCallRequest[],
3333
): Promise<CallbackCallResult[]> {
3434
return callApi(`${serverUrl}/dashi/callback`, {

dashi/src/app/PanelsControl.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const contribPoint: ContribPoint = "panels";
77
function PanelsControl() {
88
const appState = useAppStore();
99

10-
const contributionPointsResult = appState.contributionsRecordResult;
11-
const contributionPoints = contributionPointsResult.data;
12-
if (!contributionPoints) {
10+
const contributionsRecordResult = appState.contributionsRecordResult;
11+
const contributionsRecord = contributionsRecordResult.data;
12+
if (!contributionsRecord) {
1313
return null;
1414
}
15-
const panelModels = contributionPoints[contribPoint];
15+
const panelModels = contributionsRecord[contribPoint];
1616
const panelStates = appState.contributionStatesRecord[contribPoint];
1717
if (
1818
!panelModels ||

dashi/src/app/PanelsRow.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import useAppStore from "../store/appStore";
44
import Panel from "./Panel";
55
import handleComponentPropertyChange from "../actions/handleComponentPropertyChange";
66

7+
const contribPoint = "panels";
8+
79
function PanelsRow() {
810
const appState = useAppStore();
911

@@ -12,8 +14,8 @@ function PanelsRow() {
1214
let panelElements: ReactElement | null = null;
1315
const contributionsRecordResult = appState.contributionsRecordResult;
1416
if (contributionsRecordResult.data) {
15-
const panelModels = contributionsRecordResult.data["panels"];
16-
const panelStates = appState.contributionStatesRecord["panels"];
17+
const panelModels = contributionsRecordResult.data[contribPoint];
18+
const panelStates = appState.contributionStatesRecord[contribPoint];
1719
if (
1820
!panelModels ||
1921
!panelStates ||
@@ -32,7 +34,7 @@ function PanelsRow() {
3234
panelStates[panelIndex],
3335
panelEvent,
3436
);
35-
handleComponentPropertyChange("panels", panelIndex, panelEvent);
37+
handleComponentPropertyChange(contribPoint, panelIndex, panelEvent);
3638
};
3739

3840
panelElements = (

0 commit comments

Comments
 (0)