Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dataset views not loading saved attribute [PT-188345477] #71

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/hooks/use-codap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
}]);
};

const handleDataChanged = useCallback(async ({datasetName, collectionName, attributeName}: CODAPAttribute) => {
const handleDataChanged = useCallback(async (codapAttribute: CODAPAttribute, viewModeOverride?: ViewMode ) => {
const {datasetName, collectionName, attributeName} = codapAttribute;
const values = await getValuesForAttribute(datasetName, collectionName, attributeName);
const valuesChanged = !valuesRef.current || (JSON.stringify(values) !== JSON.stringify(valuesRef.current));
if (viewMode === "dataset" && valuesChanged) {
const currentViewMode = viewModeOverride ?? viewMode;
if (currentViewMode === "dataset" && valuesChanged) {
onCODAPDataChanged(values);
valuesRef.current = values;
}
Expand All @@ -100,7 +102,7 @@
} else {
if (values?.attribute) {
setAttribute(values.attribute);
handleDataChanged(values.attribute);
handleDataChanged(values.attribute, values.viewMode);
}
}
}
Expand Down Expand Up @@ -153,7 +155,7 @@
"action": "get",
"resource": "dataContextList"
}).catch((reason) => {
console.log("unable to get data context list because " + reason);

Check warning on line 158 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 158 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
});
if (tListResult?.success) {
tFoundValue = tListResult.values.find((iValue: any) => {
Expand Down Expand Up @@ -184,10 +186,10 @@
]
}
}).catch((reason) => {
console.log("unable to create output dataset because " + reason);

Check warning on line 189 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 189 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
});
if (!(tCreateResult?.success)) {
console.log("unable to create output dataset");

Check warning on line 192 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 192 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
return;
}
// setOutputDatasetID(tCreateResult.values.id);
Expand All @@ -199,7 +201,7 @@
"action": "get",
"resource": "componentList"
}).catch((reason) => {
console.log("unable to get component list because " + reason);

Check warning on line 204 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 204 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
});
if (tListResult?.success) {
tFoundValue = tListResult.values.find((iValue: any) => {
Expand All @@ -218,10 +220,10 @@
position: "top"
}
}).catch((reason) => {
console.log("unable to create case table because " + reason);

Check warning on line 223 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 223 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
});
if (!(tCreateResult?.success)) {
console.log("unable to create case table");

Check warning on line 226 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 226 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
}
}
}, []);
Expand All @@ -239,7 +241,7 @@
resource: `dataContext[${OutputDatasetName}].item`,
values: requests
}).catch((reason) => {
console.log("unable to create items because " + reason);

Check warning on line 244 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected console statement

Check warning on line 244 in src/hooks/use-codap.ts

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
});

incrementSequenceNumber();
Expand Down
Loading