diff --git a/crates/matrix-sdk-indexeddb/src/media_store/transaction.rs b/crates/matrix-sdk-indexeddb/src/media_store/transaction.rs index 9daceb7f4..0c3059f09 100644 --- a/crates/matrix-sdk-indexeddb/src/media_store/transaction.rs +++ b/crates/matrix-sdk-indexeddb/src/media_store/transaction.rs @@ -23,7 +23,7 @@ use crate::{ serializer::indexed_types::{ IndexedCoreIdKey, IndexedLeaseIdKey, IndexedMediaIdKey, IndexedMediaUriKey, }, - types::{Lease, Media, UnixTime}, + types::{Lease, Media, MediaCleanupTime, UnixTime}, }, serializer::IndexedTypeSerializer, transaction::{Transaction, TransactionError}, @@ -80,6 +80,23 @@ impl<'a> IndexeddbMediaStoreTransaction<'a> { .await } + /// Query IndexedDB for the stored [`MediaCleanupTime`] + pub async fn get_media_cleanup_time( + &self, + ) -> Result, TransactionError> { + self.transaction.get_item_by_key_components::(()).await + } + + /// Puts a media clean up time into IndexedDB. If one already exists, it + /// will be overwritten. + pub async fn put_media_cleanup_time( + &self, + time: impl Into, + ) -> Result<(), TransactionError> { + let time: MediaCleanupTime = time.into(); + self.transaction.put_item(&time).await + } + /// Query IndexedDB for [`Media`] that matches the given /// [`MediaRequestParameters`]. If more than one item is found, an error /// is returned.