Skip to content

Commit

Permalink
trigger the dirty favorite tools sync when the user adds/removes a fa…
Browse files Browse the repository at this point in the history
…vorite
  • Loading branch information
frett committed Oct 3, 2023
1 parent 5237aca commit f44f06a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/main/kotlin/org/cru/godtools/ui/tools/ToolViewModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.cru.godtools.downloadmanager.GodToolsDownloadManager
import org.cru.godtools.model.Language
import org.cru.godtools.model.Tool
import org.cru.godtools.model.Translation
import org.cru.godtools.sync.GodToolsSyncService

internal const val EXTRA_ADDITIONAL_LANGUAGE = "additionalLanguage"

Expand All @@ -42,6 +43,7 @@ class ToolViewModels @Inject constructor(
private val languagesRepository: LanguagesRepository,
private val manifestManager: ManifestManager,
private val settings: Settings,
private val syncService: GodToolsSyncService,
private val toolsRepository: ToolsRepository,
private val translationsRepository: TranslationsRepository,
savedState: SavedStateHandle,
Expand Down Expand Up @@ -123,10 +125,16 @@ class ToolViewModels @Inject constructor(
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)

fun pinTool() {
viewModelScope.launch { toolsRepository.pinTool(code) }
viewModelScope.launch {
toolsRepository.pinTool(code)
syncService.syncDirtyFavoriteTools()
}
settings.setFeatureDiscovered(Settings.FEATURE_TOOL_FAVORITE)
}
fun unpinTool() = viewModelScope.launch { toolsRepository.unpinTool(code) }
fun unpinTool() = viewModelScope.launch {
toolsRepository.unpinTool(code)
syncService.syncDirtyFavoriteTools()
}
}

private fun Flow<Tool?>.attachmentFileFlow(transform: (value: Tool?) -> Long?) = this
Expand Down

0 comments on commit f44f06a

Please sign in to comment.