Skip to content

Commit

Permalink
Updates table after sort. Only works for flat tables.
Browse files Browse the repository at this point in the history
WIP heirarchical tables.
  • Loading branch information
eireland committed Mar 19, 2024
1 parent 39c3532 commit 3eba2b2
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/hooks/useCodapState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const useCodapState = () => {
const handleDataContextChangeNotice = (iMessage: any) => {
if (iMessage.resource === `dataContextChangeNotice[${selectedDataSetName}]`) {
const theValues = iMessage.values;
console.log("***** in handleDataContextChangeNotice theValues", theValues.operation);
console.log("***** in handleDataContextChangeNotice theValues", theValues);

Check warning on line 94 in src/hooks/useCodapState.tsx

View workflow job for this annotation

GitHub Actions / Build and Run Jest Tests

Unexpected console statement

Check warning on line 94 in src/hooks/useCodapState.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
switch (theValues.operation) {
case `selectCases`:
case `updateCases`:
Expand All @@ -112,7 +112,7 @@ export const useCodapState = () => {
refreshDataSetInfo();
break;
case `moveCases`:
handleUpdateTable();
refreshTable();
break;
case "createCases":
case "createItems":
Expand All @@ -127,10 +127,8 @@ export const useCodapState = () => {
handleSetDataSet(selectedDataSetName);
};

const handleUpdateTable = () => {
console.log("***** in handleUpdateTable");
setNumUpdates(numUpdates + 1);
refreshDataSetInfo();
const refreshTable = () => {
handleUpdateTable();
};

const setUpNotifications = async () => {
Expand All @@ -141,13 +139,34 @@ export const useCodapState = () => {
setUpNotifications();
}

}, [numUpdates, selectedDataSetName]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedDataSetName]);

const updateCollections = useCallback(async () => {
const colls = await getDataSetCollections(selectedDataSet.name);
setCollections(colls);
}, [selectedDataSet]);

const handleUpdateTable = useCallback(async() => {
console.log("***** in handleUpdateTable selectedDataSetName", selectedDataSetName);

Check warning on line 151 in src/hooks/useCodapState.tsx

View workflow job for this annotation

GitHub Actions / Build and Run Jest Tests

Unexpected console statement

Check warning on line 151 in src/hooks/useCodapState.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement

const fetchCases = async () => {
const itemRes: any = await codapInterface.sendRequest({
"action": "get",
"resource": `dataContext[${selectedDataSetName}].collection[Mammals].caseSearch[*]`
});
console.log("***** in fetchCases itemRes", itemRes);

Check warning on line 158 in src/hooks/useCodapState.tsx

View workflow job for this annotation

GitHub Actions / Build and Run Jest Tests

Unexpected console statement

Check warning on line 158 in src/hooks/useCodapState.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement
const fetchedItems = itemRes.values.map((item: any) => item.values);
setItems(fetchedItems);
};

// if (dsName) {
fetchCases();
// }
// setNumUpdates(numUpdates + 1);
// refreshDataSetInfo();
}, [selectedDataSetName]);

useEffect(() => {
if (selectedDataSet) {
updateCollections();
Expand Down

0 comments on commit 3eba2b2

Please sign in to comment.