Skip to content

Commit

Permalink
Replace deprecated voyager coroutineScope
Browse files Browse the repository at this point in the history
  • Loading branch information
russellbanks committed Nov 22, 2023
1 parent bf669ac commit cefa661
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.coroutineScope
import cafe.adriel.voyager.core.model.screenModelScope
import com.appmattus.crypto.Algorithm
import com.hoc081098.flowext.interval
import components.HashProgress
Expand Down Expand Up @@ -106,7 +106,7 @@ object CompareFilesModel : ScreenModel, Klogging {

fun onCalculateClicked() {
if ((comparisonJobList?.count(Deferred<Unit>::isActive) ?: 0) <= 0) {
coroutineScope.launch(Dispatchers.Default) {
screenModelScope.launch(Dispatchers.Default) {
comparisonJobList = listOf(
async(Dispatchers.IO) {
Hashing.catchFileHashingExceptions {
Expand All @@ -125,7 +125,7 @@ object CompareFilesModel : ScreenModel, Klogging {
}
}
)
coroutineScope.launch(Dispatchers.Default) {
screenModelScope.launch(Dispatchers.Default) {
interval(Duration.ZERO, 1.seconds)
.takeWhile { comparisonJobList?.first()?.isActive == true }
.collect {
Expand All @@ -135,7 +135,7 @@ object CompareFilesModel : ScreenModel, Klogging {
)
}
}
coroutineScope.launch(Dispatchers.Default) {
screenModelScope.launch(Dispatchers.Default) {
interval(Duration.ZERO, 1.seconds)
.takeWhile { comparisonJobList?.get(1)?.isActive == true }
.collect {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/components/screens/file/FileScreenModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.SnapshotStateMap
import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.coroutineScope
import cafe.adriel.voyager.core.model.screenModelScope
import com.appmattus.crypto.Algorithm
import com.hoc081098.flowext.interval
import components.Timer
Expand Down Expand Up @@ -69,14 +69,14 @@ object FileScreenModel : ScreenModel {
fun onCalculateClicked() {
file?.let { file ->
if (fileHashJob?.isActive != true) {
coroutineScope.launch(Dispatchers.Default) {
screenModelScope.launch(Dispatchers.Default) {
interval(Duration.ZERO, 1.seconds)
.takeWhile { fileHashJob?.isActive == true }
.collect {
timer = Timer(minutes = it.toDuration(DurationUnit.SECONDS).inWholeMinutes, seconds = it)
}
}
fileHashJob = coroutineScope.launch(Dispatchers.IO) {
fileHashJob = screenModelScope.launch(Dispatchers.IO) {
instantBeforeHash = Clock.System.now()
Hashing.catchFileHashingExceptions(exceptionCallback = { exception = it }) {
resultMap[ParentComponent.algorithm] = file.hash(
Expand Down

0 comments on commit cefa661

Please sign in to comment.