Updated on 2026-08-14
This commit is contained in:
parent
49800731e3
commit
d664e6ecbb
13 changed files with 267 additions and 39 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.datasource.di
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeDataStore
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
import com.tangem.datasource.local.swap.DefaultSwapBestRateAnimationStore
|
||||
import com.tangem.datasource.local.swap.DefaultSwapTransactionStatusStore
|
||||
import com.tangem.datasource.local.swap.SwapBestRateAnimationStore
|
||||
|
|
@ -22,4 +23,12 @@ object SwapStoreModule {
|
|||
dataStore = RuntimeDataStore(),
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideSwapBestRateAnimationStore(): SwapBestRateAnimationStore {
|
||||
return DefaultSwapBestRateAnimationStore(
|
||||
dataStore = RuntimeSharedStore(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.tangem.datasource.local.swap
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
|
||||
internal class DefaultSwapBestRateAnimationStore(
|
||||
private val dataStore: RuntimeSharedStore<Boolean>,
|
||||
) : SwapBestRateAnimationStore, RuntimeSharedStore<Boolean> by dataStore {
|
||||
/**
|
||||
* Returns flag indicating whether should show best rate animation in current session.
|
||||
* Animation should appear once per session
|
||||
*
|
||||
* If true, reset flag to false
|
||||
*/
|
||||
override suspend fun getSyncOrNull(): Boolean {
|
||||
val value = dataStore.getSyncOrNull() ?: true
|
||||
if (value) {
|
||||
dataStore.store(false)
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.datasource.local.swap
|
||||
|
||||
/**
|
||||
* Stores flag indicating whether should show best rate animation in current session.
|
||||
* Animation should appear once per session
|
||||
*
|
||||
* If true, reset flag to false
|
||||
*/
|
||||
interface SwapBestRateAnimationStore {
|
||||
suspend fun getSyncOrNull(): Boolean
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue