Skip to content

Commit 03a76fb

Browse files
mgoldenbergHywan
authored andcommitted
feat(indexeddb): add IndexedDB-backed impl for EventCacheStore::clear_all_linked_chunks
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
1 parent 392a1ef commit 03a76fb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

crates/matrix-sdk-indexeddb/src/event_cache_store/integration_tests.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ macro_rules! event_cache_store_integration_tests {
728728
event_cache_store.test_rebuild_empty_linked_chunk().await;
729729
}
730730

731+
#[async_test]
732+
async fn test_clear_all_linked_chunks() {
733+
let event_cache_store =
734+
get_event_cache_store().await.unwrap().into_event_cache_store();
735+
event_cache_store.test_clear_all_linked_chunks().await;
736+
}
737+
731738
#[async_test]
732739
async fn test_remove_room() {
733740
let event_cache_store =

crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,15 @@ impl_event_cache_store! {
369369
}
370370

371371
async fn clear_all_linked_chunks(&self) -> Result<(), IndexeddbEventCacheStoreError> {
372-
self.memory_store
373-
.clear_all_linked_chunks()
374-
.await
375-
.map_err(IndexeddbEventCacheStoreError::MemoryStore)
372+
let transaction = self.transaction(
373+
&[keys::LINKED_CHUNKS, keys::EVENTS, keys::GAPS],
374+
IdbTransactionMode::Readwrite,
375+
)?;
376+
transaction.clear::<types::Chunk>().await?;
377+
transaction.clear::<types::Event>().await?;
378+
transaction.clear::<types::Gap>().await?;
379+
transaction.commit().await?;
380+
Ok(())
376381
}
377382

378383
async fn filter_duplicated_events(

0 commit comments

Comments
 (0)