Skip to content

Commit

Permalink
Save last selected hashing algorithm in checksum tools
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Jan 15, 2025
1 parent c501e09 commit cc16c19
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import ru.tech.imageresizershrinker.core.domain.dispatchers.DispatchersHolder
import ru.tech.imageresizershrinker.core.domain.model.HashingType
import ru.tech.imageresizershrinker.core.domain.saving.FileController
import ru.tech.imageresizershrinker.core.ui.utils.BaseComponent
import ru.tech.imageresizershrinker.core.ui.utils.state.update
import ru.tech.imageresizershrinker.feature.checksum_tools.domain.ChecksumManager
Expand All @@ -38,6 +39,7 @@ class ChecksumToolsComponent @AssistedInject constructor(
@Assisted initialUri: Uri?,
@Assisted val onGoBack: () -> Unit,
private val checksumManager: ChecksumManager,
private val fileController: FileController,
dispatchersHolder: DispatchersHolder
) : BaseComponent(dispatchersHolder, componentContext) {

Expand All @@ -61,6 +63,10 @@ class ChecksumToolsComponent @AssistedInject constructor(
init {
debounce {
initialUri?.let(::setUri)
fileController.restoreObject(
key = "checksum_type",
kClass = HashingType::class
)?.let(::updateChecksumType)
}
}

Expand Down Expand Up @@ -141,6 +147,12 @@ class ChecksumToolsComponent @AssistedInject constructor(
calculateFromUriPage.uri?.let(::setUri)
calculateFromTextPage.text.let(::setText)
compareWithUriPage.uri?.let(::setDataForComparison)
componentScope.launch {
fileController.saveObject(
key = "checksum_type",
value = type
)
}
}

@AssistedFactory
Expand Down

0 comments on commit cc16c19

Please sign in to comment.