fix loading handle - #262
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors how document handles are obtained (migrating from useRepo to a global store selector), adds safety guards around possibly undefined handles in various hooks, and cleans up imports and error logging.
- Switch
useSubscribeToSpaceAndGetHandleto useuseSelectorfrom the store instead ofuseRepo - Add checks for undefined handles in all
use*Entityand query hooks, returning throwing stubs or fallbacks - Remove unused imports and comment out console errors in the App context
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/hypergraph-react/src/HypergraphSpaceContext.tsx | Migrate handle lookup to selector and guard undefined handles in hooks |
| packages/hypergraph-react/src/HypergraphAppContext.tsx | Consolidate type imports and comment out stray console.error |
| apps/events/src/components/users.tsx | Remove hardcoded space ID from useCreateEntity call |
Comments suppressed due to low confidence (3)
packages/hypergraph-react/src/HypergraphSpaceContext.tsx:8
- The cleanup callback in
useSubscribeToSpaceAndGetHandleis currently empty, which may lead to orphaned subscriptions ifspaceIdorenabledchanges. Implement an unsubscribe call there to avoid memory leaks.
createContext,
packages/hypergraph-react/src/HypergraphSpaceContext.tsx:69
- [nitpick] The hooks use different destructuring names (
spacevsspaceIdFromParams) across functions, which can be confusing. Consider standardizing on a single parameter name likespaceIdfor clarity.
const { space: spaceIdFromParams } = options ?? {};
apps/events/src/components/users.tsx:11
- Removing the explicit
spaceargument changes the hook's behavior to rely on context. Ensure the context always provides the correct space or re-introduce the explicit ID if multi-space usage is expected.
const createEntity = useCreateEntity(User);
Comment on lines
+364
to
369
| // console.error( | ||
| // `Received invalid signature, recovered signer is ${signer}, | ||
| // expected ${authorIdentity.signaturePublicKey}`, | ||
| // ); | ||
| // TODO bring back signature verfication | ||
| // return { valid: false, update: new Uint8Array([]) }; |
There was a problem hiding this comment.
Commented-out logging can clutter the codebase. Either remove the dead code or re-enable the check with a proper logging strategy and a clear TODO note.
Suggested change
| // console.error( | |
| // `Received invalid signature, recovered signer is ${signer}, | |
| // expected ${authorIdentity.signaturePublicKey}`, | |
| // ); | |
| // TODO bring back signature verfication | |
| // return { valid: false, update: new Uint8Array([]) }; | |
| console.error( | |
| `Received invalid signature, recovered signer is ${signer}, expected ${authorIdentity.signaturePublicKey}` | |
| ); | |
| // TODO: Implement signature verification logic here to handle invalid signatures. | |
| return { valid: false, update: new Uint8Array([]) }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.