Skip to content

Commit

Permalink
trigger the favorite tools sync from the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
frett committed Oct 2, 2023
1 parent 118feeb commit 491f71f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -53,7 +54,10 @@ class DashboardViewModel @Inject constructor(
@Suppress("DeferredResultUnused")
syncService.syncToolSharesAsync()
syncsRunning.value++
syncService.syncTools(force)
coroutineScope {
launch { syncService.syncFavoriteTools(force) }
launch { syncService.syncTools(force) }
}
syncsRunning.value--
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ExternalSingletonsModule {
val syncService: GodToolsSyncService by lazy {
mockk {
coEvery { syncTools(any()) } returns true
coEvery { syncFavoriteTools(any()) } returns true
every { syncFollowupsAsync() } returns CompletableDeferred(true)
every { syncToolSharesAsync() } returns CompletableDeferred(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DashboardViewModelTest {
every { syncFollowupsAsync() } returns CompletableDeferred()
every { syncToolSharesAsync() } returns CompletableDeferred()
coEvery { syncTools(any()) } returns true
coEvery { syncFavoriteTools(any()) } returns true
}
private val testScope = TestScope()

Expand All @@ -59,6 +60,7 @@ class DashboardViewModelTest {
syncService.syncFollowupsAsync()
syncService.syncToolSharesAsync()
syncService.syncTools(false)
syncService.syncFavoriteTools(false)
}
}

Expand Down Expand Up @@ -90,7 +92,8 @@ class DashboardViewModelTest {
coVerifyAll {
syncService.syncFollowupsAsync()
syncService.syncToolSharesAsync()
syncService.syncTools(any())
syncService.syncTools(false)
syncService.syncFavoriteTools(false)
}
}
}

0 comments on commit 491f71f

Please sign in to comment.