Skip to content

Comments

Optimize Objects page loading#59

Merged
Bakuutin merged 16 commits intodevfrom
objects-favorites
Feb 12, 2026
Merged

Optimize Objects page loading#59
Bakuutin merged 16 commits intodevfrom
objects-favorites

Conversation

@skywinder
Copy link
Collaborator

@skywinder skywinder commented Jan 31, 2026

Summary

  • Optimize Objects page loading: Load counts instantly from cache, lazy-load object lists only when sections are expanded

Changes

Frontend (ObjectsPage.tsx)

  • Sections start collapsed, first section with items auto-expands
  • Counts load immediately from cache, object lists load on-demand
  • Only expanded sections refetch on navigation/visibility change
  • Starred objects fetch in parallel with counts

Performance

  • getCounts now returns stale cache immediately, refreshes in background
  • Initial page load reduced from 6-7 parallel aggregations to 2 fast requests

Test plan

  • Verify /objects page loads quickly with counts visible
  • Expand a section and verify objects load
  • Change filters/search and verify data refreshes correctly
  • Test starred objects functionality

…th alias display

- Introduced 'starred' boolean property to resource and object schemas for user flagging.
- Updated ConversationsPage to display aliases for conversations, including a badge for each alias and a count for additional aliases.
- Enhanced ObjectCard component to support toggling the starred state with a visual star button.
- Introduced separate methods for refreshing type counts and orphaned counts to improve performance and clarity.
- Updated the refreshCounts method to aggregate type counts and orphaned counts efficiently.
- Enhanced the getCachedCounts method to include tag counts.
- Modified the ObjectCard component to support the new tag type and adjusted UI elements for better usability and consistency.

This comment was marked as off-topic.

Added auth: Auth parameter to the method
Added const mongo = getMongoResource(auth) at the start
Bug 2 - Duplicate refreshTypeCountsOnly() method:
Removed the second duplicate definition (was at lines 493-559)
Kept only one implementation with the proper auth parameter
Bug 3 - refreshTypeCountsOnly(auth) called with auth but method didn't accept it:
Added auth: Auth parameter to both refreshTypeCountsOnly() and refreshCounts()
Updated all internal calls to pass auth through (refreshTypeCounts(auth), refreshOrphanedCount(auth))
Fixed the background refresh call at line 1290 to pass auth
Bug 4 - "other" type filter not excluding isTag:
Added isTag: { $ne: true } to the getTypeMatch("other") return value in ObjectsPage.tsx
Also fixed the refreshTypeCounts aggregation in the backend to exclude isTag from the "other" count
Bug 5 - Stale closure in undo toast callback:
Replaced the recursive toggleStar() call with inline logic that captures removedObject at toast creation time
The undo handler now uses capturedObject (a copy made at toast time) to restore state
Changed the dependency array to [] since the callback no longer relies on external state from the closure
- Added 'isTag' to typeFields in ObjectsResource to support new object type.
- Improved toggleStar functionality in ObjectsPage to capture the found object during optimistic UI updates, enhancing the user experience for starring and unstarring objects.
@skywinder skywinder changed the title Optimize Objects page loading & refactor backend Optimize Objects page loading Jan 31, 2026
skywinder and others added 6 commits January 31, 2026 16:43
- Introduced `linkedObjectsCount` to the ObjectCardProps interface to display the number of objects linked to a tag.
- Updated the MongoDB aggregation pipeline to calculate and include the linked objects count for tags.
- Enhanced the UI to show the linked objects count conditionally for tag types.
- Simplified the header by removing the container div around the title and starred objects button.
- Maintained the functionality of the starred objects button while improving the overall UI structure.
@Bakuutin Bakuutin merged commit b55c6e3 into dev Feb 12, 2026
2 checks passed
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