Skip to content

feat(indexeddb): implement Event-related functions in EventCacheStore #5414

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

Merged

Conversation

mgoldenberg
Copy link
Contributor

@mgoldenberg mgoldenberg commented Jul 15, 2025

Background

This pull request is part of a series of pull requests to add a full IndexedDB implementation of the EventCacheStore (see #4617, #4996, #5090, #5138, #5226, #5274, #5343, #5384, #5406). This particular pull request focuses on providing implementations for the Event-related functions in EventCacheStore.

Changes

The changes include implementations of the following functions, as well as tests for each of them.

  • EventCacheStore::filter_duplicated_events
  • EventCacheStore::find_event
  • EventCacheStore::find_event_relations
  • EventCacheStore::save_event

I have also added a few other functions which support the implementation of the functions above.

  • IndexedEventRelationKey::set_related_event
  • IndexeddbEventCacheStoreTransaction::get_event_by_id
  • IndexeddbEventCacheStoreTransaction::get_events_by_relation
  • IndexeddbEventCacheStoreTransaction::get_events_by_related_event

Bug Fixes

There is also a small change to how Update::PushItems is handled. Namely, if a given item already exists in the database, it will update that item, rather than returning an error. The new behavior is consistent with the SQLite implementation of EventCacheStore (see here).

This bug was surfaced by matrix_sdk_base::event_cache::store::integration_tests::test_find_event_relations.

Future Work

  • Add implementation of EventCacheStore::try_take_leased_lock functions without relying on MemoryStore
  • Add implementation of EventCacheStoreMedia

  • Public API changes documented in changelogs (optional)

Signed-off-by: Michael Goldenberg m@mgoldenberg.net

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.85%. Comparing base (0e622cc) to head (45db71f).
Report is 5 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5414      +/-   ##
==========================================
- Coverage   88.85%   88.85%   -0.01%     
==========================================
  Files         333      333              
  Lines       91547    91547              
  Branches    91547    91547              
==========================================
- Hits        81343    81340       -3     
- Misses       6379     6382       +3     
  Partials     3825     3825              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mgoldenberg mgoldenberg marked this pull request as ready for review July 15, 2025 17:04
@mgoldenberg mgoldenberg requested a review from a team as a code owner July 15, 2025 17:04
@mgoldenberg mgoldenberg requested review from Hywan and removed request for a team July 15, 2025 17:04
@poljar poljar requested review from poljar and removed request for Hywan July 22, 2025 09:39
@bnjbvr
Copy link
Member

bnjbvr commented Jul 22, 2025

Thanks for the PR! Stealing review, as I'm more acquainted with the event cache.

@bnjbvr bnjbvr requested review from bnjbvr and removed request for poljar July 22, 2025 15:41
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Sorry about the long review time! Holidays make it so that there are fewer of us working around this time.

Looks good in general, there's a tiny logic issue in the first commit, but the rest looks great, thanks!

@mgoldenberg mgoldenberg requested a review from bnjbvr July 22, 2025 17:11
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Thanks, with the linked-chunk-id keying postponed to later, LGTM 👍

@bnjbvr bnjbvr changed the title IndexedDB: Add IndexedDB implementation of Event-related functions in EventCacheStore feat(indexeddb): implement Event-related functions in EventCacheStore Jul 23, 2025
…r_duplicated_events

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
…event

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
…event

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
… item already exists

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
…event_relations

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
@bnjbvr bnjbvr force-pushed the indexeddb-event-cache-store-event-fns branch from 4799ce1 to 45db71f Compare July 23, 2025 15:50
@bnjbvr bnjbvr enabled auto-merge (rebase) July 23, 2025 15:58
@bnjbvr bnjbvr merged commit ada68e1 into matrix-org:main Jul 23, 2025
43 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