Skip to content

Conversation

gmaclennan
Copy link
Member

@gmaclennan gmaclennan commented Aug 28, 2025

$originalVersionIdToDeviceId() maps a versionId to a deviceId. It was a temporary workaround for this information not being included in the docs returned from the server, but it adds RPC round-trip overhead. The result of this query never changes for a given versionId, so it does not need to be refetched and can be cached for ever. Because there are never going to be more than a few hundred deviceIds in a project, I think it's ok to never garbage collect this data, and just keep them cached for ever.

This small change should reduce the number of RPC requests when re-visiting the observation list page.

This is a short-term fix — the longer-term fix is to return a createdBy field on docs returned from core, removing the need for the useDocumentCreatedBy() hook: digidem/comapeo-core#136

$originalVersionIdToDeviceId maps a versionId to a deviceId. It was a temporary workaround for this information not being included in the docs returned from the server, but it adds RPC round-trip overhead. The result of this query never changes for a given versionId, so it does not need to be refetched and can be cached for ever. Because there are never going to be more than a few hundred deviceIds in a project, I think it's ok to never garbage collect this data, and just keep them cached for ever.

This small change should reduce the number of RPC requests when re-visiting the observation list page.
@gmaclennan gmaclennan self-assigned this Aug 28, 2025
@gmaclennan gmaclennan marked this pull request as ready for review August 28, 2025 10:43
@gmaclennan gmaclennan requested a review from achou11 August 28, 2025 10:43
@gmaclennan gmaclennan changed the title feat: never refetch created by mapping feat: never refetch with useDocumentCreatedBy() Aug 28, 2025
@gmaclennan gmaclennan merged commit 146dd04 into main Aug 28, 2025
5 checks passed
@gmaclennan gmaclennan deleted the feat/static-created-by branch August 28, 2025 13:45
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