@@ -28,7 +28,9 @@ use std::{rc::Rc, time::Duration};
2828
2929pub use builder:: IndexeddbMediaStoreBuilder ;
3030pub use error:: IndexeddbMediaStoreError ;
31- use indexed_db_futures:: { cursor:: CursorDirection , database:: Database , Build } ;
31+ use indexed_db_futures:: {
32+ cursor:: CursorDirection , database:: Database , transaction:: TransactionMode , Build ,
33+ } ;
3234use matrix_sdk_base:: {
3335 media:: {
3436 store:: {
@@ -41,7 +43,6 @@ use matrix_sdk_base::{
4143} ;
4244use ruma:: { time:: SystemTime , MilliSecondsSinceUnixEpoch , MxcUri } ;
4345use tracing:: instrument;
44- use web_sys:: IdbTransactionMode ;
4546
4647use crate :: {
4748 media_store:: {
@@ -81,7 +82,7 @@ impl IndexeddbMediaStore {
8182 pub fn transaction < ' a > (
8283 & ' a self ,
8384 stores : & [ & str ] ,
84- mode : IdbTransactionMode ,
85+ mode : TransactionMode ,
8586 ) -> Result < IndexeddbMediaStoreTransaction < ' a > , IndexeddbMediaStoreError > {
8687 Ok ( IndexeddbMediaStoreTransaction :: new (
8788 self . inner
@@ -110,8 +111,7 @@ impl MediaStore for IndexeddbMediaStore {
110111
111112 let now = Duration :: from_millis ( MilliSecondsSinceUnixEpoch :: now ( ) . get ( ) . into ( ) ) ;
112113
113- let transaction =
114- self . transaction ( & [ Lease :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
114+ let transaction = self . transaction ( & [ Lease :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
115115
116116 if let Some ( lease) = transaction. get_lease_by_id ( key) . await ? {
117117 if lease. holder != holder && !lease. has_expired ( now) {
@@ -149,8 +149,7 @@ impl MediaStore for IndexeddbMediaStore {
149149 ) -> Result < ( ) , IndexeddbMediaStoreError > {
150150 let _timer = timer ! ( "method" ) ;
151151
152- let transaction =
153- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
152+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
154153 if let Some ( mut media) = transaction. get_media_by_id ( from) . await ? {
155154 // delete before adding, in case `from` and `to` generate the same key
156155 transaction. delete_media_by_id ( from) . await ?;
@@ -177,8 +176,7 @@ impl MediaStore for IndexeddbMediaStore {
177176 ) -> Result < ( ) , IndexeddbMediaStoreError > {
178177 let _timer = timer ! ( "method" ) ;
179178
180- let transaction =
181- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
179+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
182180 transaction. delete_media_by_id ( request) . await ?;
183181 transaction. commit ( ) . await . map_err ( Into :: into)
184182 }
@@ -199,8 +197,7 @@ impl MediaStore for IndexeddbMediaStore {
199197 ) -> Result < ( ) , IndexeddbMediaStoreError > {
200198 let _timer = timer ! ( "method" ) ;
201199
202- let transaction =
203- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
200+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
204201 transaction. delete_media_by_uri ( uri) . await ?;
205202 transaction. commit ( ) . await . map_err ( Into :: into)
206203 }
@@ -247,7 +244,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
247244 & self ,
248245 ) -> Result < Option < MediaRetentionPolicy > , IndexeddbMediaStoreError > {
249246 let _timer = timer ! ( "method" ) ;
250- self . transaction ( & [ MediaRetentionPolicy :: OBJECT_STORE ] , IdbTransactionMode :: Readonly ) ?
247+ self . transaction ( & [ MediaRetentionPolicy :: OBJECT_STORE ] , TransactionMode :: Readonly ) ?
251248 . get_media_retention_policy ( )
252249 . await
253250 . map_err ( Into :: into)
@@ -261,7 +258,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
261258 let _timer = timer ! ( "method" ) ;
262259
263260 let transaction =
264- self . transaction ( & [ MediaRetentionPolicy :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
261+ self . transaction ( & [ MediaRetentionPolicy :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
265262 transaction. put_item ( & policy) . await ?;
266263 transaction. commit ( ) . await . map_err ( Into :: into)
267264 }
@@ -277,8 +274,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
277274 ) -> Result < ( ) , IndexeddbMediaStoreError > {
278275 let _timer = timer ! ( "method" ) ;
279276
280- let transaction =
281- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
277+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
282278
283279 let media = Media {
284280 metadata : MediaMetadata {
@@ -301,8 +297,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
301297 ) -> Result < ( ) , IndexeddbMediaStoreError > {
302298 let _timer = timer ! ( "method" ) ;
303299
304- let transaction =
305- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
300+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
306301 if let Some ( mut media) = transaction. get_media_by_id ( request) . await ? {
307302 if media. metadata . ignore_policy != ignore_policy {
308303 media. metadata . ignore_policy = ignore_policy;
@@ -321,8 +316,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
321316 ) -> Result < Option < Vec < u8 > > , IndexeddbMediaStoreError > {
322317 let _timer = timer ! ( "method" ) ;
323318
324- let transaction =
325- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
319+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
326320 let media = transaction. access_media_by_id ( request, current_time) . await ?;
327321 transaction. commit ( ) . await ?;
328322 Ok ( media. map ( |m| m. content ) )
@@ -336,8 +330,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
336330 ) -> Result < Option < Vec < u8 > > , IndexeddbMediaStoreError > {
337331 let _timer = timer ! ( "method" ) ;
338332
339- let transaction =
340- self . transaction ( & [ Media :: OBJECT_STORE ] , IdbTransactionMode :: Readwrite ) ?;
333+ let transaction = self . transaction ( & [ Media :: OBJECT_STORE ] , TransactionMode :: Readwrite ) ?;
341334 let media = transaction. access_media_by_uri ( uri, current_time) . await ?. pop ( ) ;
342335 transaction. commit ( ) . await ?;
343336 Ok ( media. map ( |m| m. content ) )
@@ -357,7 +350,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
357350
358351 let transaction = self . transaction (
359352 & [ Media :: OBJECT_STORE , MediaCleanupTime :: OBJECT_STORE ] ,
360- IdbTransactionMode :: Readwrite ,
353+ TransactionMode :: Readwrite ,
361354 ) ?;
362355
363356 let ignore_policy = IgnoreMediaRetentionPolicy :: No ;
@@ -418,7 +411,7 @@ impl MediaStoreInner for IndexeddbMediaStore {
418411 ) -> Result < Option < SystemTime > , IndexeddbMediaStoreError > {
419412 let _timer = timer ! ( "method" ) ;
420413 let time = self
421- . transaction ( & [ MediaCleanupTime :: OBJECT_STORE ] , IdbTransactionMode :: Readonly ) ?
414+ . transaction ( & [ MediaCleanupTime :: OBJECT_STORE ] , TransactionMode :: Readonly ) ?
422415 . get_media_cleanup_time ( )
423416 . await ?;
424417 Ok ( time. map ( Into :: into) )
0 commit comments