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

Move settings data model refreshMetadata to sync calls #9046

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

charlesBochet
Copy link
Member

@charlesBochet charlesBochet commented Dec 12, 2024

In this PR, I'm

  • removing setting up the isAppWaitingForFreshMetadata boolean state in PageChangeEffect navigate (not robust) to some precise synchronous places, improving the control we have on when the app considers it's ready to be rendered based on fresh metadata
  • fixing tests

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR modifies how metadata refresh operations are handled across the application, moving from Apollo's built-in refetchQueries to explicit synchronous refresh calls.

  • Removed Apollo's refetchQueries in favor of explicit refreshObjectMetadataItems() calls across multiple metadata hooks
  • Added network-only fetch policy to useRefreshObjectMetadataItems for stronger cache control
  • Commented out navigation-triggered metadata refresh in PageChangeEffect.tsx, potentially affecting state management
  • Left debugging console.log statements in ObjectMetadataItemsGater and ObjectMetadataItemsProvider that should be removed
  • Modified useLoadMockedObjectMetadataItems to handle isAppWaitingForFreshObjectMetadataState synchronization

13 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -11,6 +11,8 @@ export const ObjectMetadataItemsGater = ({
isAppWaitingForFreshObjectMetadataState,
);

console.log(isAppWaitingForFreshObjectMetadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Remove debugging console.log before merging to production

@@ -11,6 +11,7 @@ export const ObjectMetadataItemsProvider = ({
children,
}: React.PropsWithChildren) => {
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
console.log('objectMetadataItems', objectMetadataItems);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Remove console.log statement before merging to production

Comment on lines +33 to 35
const result = await mutate({
variables: { input: { relation: formatRelationMetadataInput(input) } },
awaitRefetchQueries: true,
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: No error handling around the mutation. Consider wrapping in try/catch to handle potential network or validation errors.

});

await refreshObjectMetadataItems();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: refreshObjectMetadataItems could fail silently if the network request fails, potentially leaving the UI in an inconsistent state

Comment on lines +27 to 33
const result = await mutate({
variables: {
input: {
field: input,
},
},
awaitRefetchQueries: true,
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider handling mutation errors before proceeding with refresh

Comment on lines +29 to +36
const result = await mutate({
variables: {
idToDelete,
},
awaitRefetchQueries: true,
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
});

await refreshObjectMetadataItems();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: No error handling around the mutation or refresh call. If either fails, the error is silently propagated.

Comment on lines +28 to +35
const result = await mutate({
variables: {
idToDelete,
},
awaitRefetchQueries: true,
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
});

await refreshObjectMetadataItems();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider handling mutation errors before calling refreshObjectMetadataItems to avoid unnecessary refreshes on failure

Comment on lines 42 to 44
set(objectMetadataItemsState, toSetObjectMetadataItems);
set(isAppWaitingForFreshObjectMetadataState, false);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: setting isAppWaitingForFreshObjectMetadataState to false here but never setting it to true anywhere in this flow

});

await refreshObjectMetadataItems();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider wrapping refreshObjectMetadataItems in try/catch to handle refresh failures gracefully

});

await refreshObjectMetadataItems();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider error handling around refreshObjectMetadataItems call - if it fails, the workspace and views may be out of sync

@charlesBochet charlesBochet merged commit 9579f22 into main Dec 13, 2024
19 checks passed
@charlesBochet charlesBochet deleted the fix-snackbar-error branch December 13, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants