Skip to content

Commit 2e7721b

Browse files
mgoldenbergHywan
authored andcommitted
feat(indexeddb): add IndexedDB-backed impl for EventCacheStore::load_all_chunks
Signed-off-by: Michael Goldenberg <[email protected]>
1 parent a514019 commit 2e7721b

File tree

1 file changed

+19
-4
lines changed
  • crates/matrix-sdk-indexeddb/src/event_cache_store

1 file changed

+19
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,25 @@ impl_event_cache_store! {
260260
&self,
261261
linked_chunk_id: LinkedChunkId<'_>,
262262
) -> Result<Vec<RawChunk<Event, Gap>>, IndexeddbEventCacheStoreError> {
263-
self.memory_store
264-
.load_all_chunks(linked_chunk_id)
265-
.await
266-
.map_err(IndexeddbEventCacheStoreError::MemoryStore)
263+
let linked_chunk_id = linked_chunk_id.to_owned();
264+
let room_id = linked_chunk_id.room_id();
265+
266+
let transaction = self.transaction(
267+
&[keys::LINKED_CHUNKS, keys::GAPS, keys::EVENTS],
268+
IdbTransactionMode::Readwrite,
269+
)?;
270+
271+
let mut raw_chunks = Vec::new();
272+
let chunks = transaction.get_chunks_in_room(room_id).await?;
273+
for chunk in chunks {
274+
if let Some(raw_chunk) = transaction
275+
.load_chunk_by_id(room_id, &ChunkIdentifier::new(chunk.identifier))
276+
.await?
277+
{
278+
raw_chunks.push(raw_chunk);
279+
}
280+
}
281+
Ok(raw_chunks)
267282
}
268283

269284
async fn load_all_chunks_metadata(

0 commit comments

Comments
 (0)