mirror of
https://github.com/FluxaMedia/fluxa.git
synced 2026-08-16 12:13:47 +00:00
Sync addon changes to Nuvio
This commit is contained in:
parent
7c26c9d832
commit
273fb1ef70
3 changed files with 32 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ internal fun installLocalAddonForProfile(
|
|||
onProfileChanged(updated)
|
||||
profileManager.saveProfileReplacingLocalAddons(updated)
|
||||
profileManager.setLastActiveProfile(updated)
|
||||
homeViewModel.pushNuvioAddons(updated)
|
||||
homeViewModel.loadInitialData(updated, force = true)
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +47,7 @@ internal fun removeLocalAddonForProfile(
|
|||
onProfileChanged(updated)
|
||||
profileManager.saveProfileReplacingLocalAddons(updated)
|
||||
profileManager.setLastActiveProfile(updated)
|
||||
homeViewModel.pushNuvioAddons(updated)
|
||||
homeViewModel.loadInitialData(updated, force = true)
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +71,7 @@ internal fun moveLocalAddonForProfile(
|
|||
onProfileChanged(updated)
|
||||
profileManager.saveProfileReplacingLocalAddons(updated)
|
||||
profileManager.setLastActiveProfile(updated)
|
||||
homeViewModel.pushNuvioAddons(updated)
|
||||
homeViewModel.loadInitialData(updated, force = true)
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +99,7 @@ internal fun setLocalAddonEnabledForProfile(
|
|||
onProfileChanged(updated)
|
||||
profileManager.saveProfileReplacingLocalAddons(updated)
|
||||
profileManager.setLastActiveProfile(updated)
|
||||
homeViewModel.pushNuvioAddons(updated)
|
||||
homeViewModel.loadInitialData(updated, force = true)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1324,6 +1324,12 @@ class HomeViewModel @Inject constructor(
|
|||
|
||||
suspend fun isNuvioHealthy(): Boolean = nuvioSyncCoordinator.isHealthy()
|
||||
|
||||
fun pushNuvioAddons(profile: UserProfile) {
|
||||
viewModelScope.launch {
|
||||
runCatching { nuvioSyncCoordinator.pushAddons(profile) }
|
||||
}
|
||||
}
|
||||
|
||||
fun syncStremioIntegration(
|
||||
profile: UserProfile,
|
||||
onProfileUpdated: (UserProfile) -> Unit,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,28 @@ class NuvioSyncCoordinator @Inject constructor(
|
|||
).requireSuccess()
|
||||
profileManager.saveProfile(current.copy(nuvioLastSyncAt = System.currentTimeMillis()))
|
||||
}
|
||||
|
||||
suspend fun pushAddons(profile: UserProfile) {
|
||||
val current = freshProfile(profile) ?: return
|
||||
val token = current.nuvioAccessToken ?: return
|
||||
val index = current.nuvioProfileIndex ?: return
|
||||
val disabled = current.safeDisabledLocalAddonIds
|
||||
nuvioService.pushAddons(
|
||||
"Bearer $token",
|
||||
mapOf(
|
||||
"p_profile_id" to index,
|
||||
"p_addons" to current.safeInstalledLocalAddons.mapIndexed { sortOrder, url ->
|
||||
mapOf(
|
||||
"url" to url,
|
||||
"name" to url,
|
||||
"enabled" to (com.fluxa.app.domain.discovery.StremioAddonUrls.identity(url) !in disabled),
|
||||
"sort_order" to sortOrder
|
||||
)
|
||||
}
|
||||
)
|
||||
).requireSuccess()
|
||||
profileManager.saveProfile(current.copy(nuvioLastSyncAt = System.currentTimeMillis()))
|
||||
}
|
||||
suspend fun pushWatchlist(profile: UserProfile, meta: Meta, isInWatchlist: Boolean) {
|
||||
val current = freshProfile(profile) ?: return
|
||||
val token = current.nuvioAccessToken ?: return
|
||||
|
|
|
|||
Loading…
Reference in a new issue