mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Disable subtitle download button if user doesn't have permission (#671)
## Description Just a UI change to disable the Search & Download subtitles button if the user doesn't have permission to manage subtitles. This avoids the 403 error if the user attempts to use it. ### Related issues Closes #483
This commit is contained in:
parent
ed67e5575f
commit
2377a15611
3 changed files with 9 additions and 0 deletions
|
|
@ -53,6 +53,7 @@ data class PlaybackSettings(
|
||||||
val playbackSpeed: Float,
|
val playbackSpeed: Float,
|
||||||
val contentScale: ContentScale,
|
val contentScale: ContentScale,
|
||||||
val subtitleDelay: Duration,
|
val subtitleDelay: Duration,
|
||||||
|
val hasSubtitleDownloadPermission: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -96,6 +97,7 @@ fun PlaybackDialog(
|
||||||
SubtitleChoiceBottomDialog(
|
SubtitleChoiceBottomDialog(
|
||||||
choices = settings.subtitleStreams,
|
choices = settings.subtitleStreams,
|
||||||
currentChoice = settings.subtitleIndex,
|
currentChoice = settings.subtitleIndex,
|
||||||
|
hasDownloadPermission = settings.hasSubtitleDownloadPermission,
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
onControllerInteraction.invoke()
|
onControllerInteraction.invoke()
|
||||||
onDismissRequest.invoke()
|
onDismissRequest.invoke()
|
||||||
|
|
@ -275,6 +277,7 @@ fun SubtitleChoiceBottomDialog(
|
||||||
onSelectChoice: (Int) -> Unit,
|
onSelectChoice: (Int) -> Unit,
|
||||||
onSelectSearch: () -> Unit,
|
onSelectSearch: () -> Unit,
|
||||||
gravity: Int,
|
gravity: Int,
|
||||||
|
hasDownloadPermission: Boolean,
|
||||||
currentChoice: Int? = null,
|
currentChoice: Int? = null,
|
||||||
) {
|
) {
|
||||||
// TODO enforcing a width ends up ignore the gravity
|
// TODO enforcing a width ends up ignore the gravity
|
||||||
|
|
@ -366,6 +369,7 @@ fun SubtitleChoiceBottomDialog(
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
ListItem(
|
ListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
|
enabled = hasDownloadPermission,
|
||||||
onClick = onSelectSearch,
|
onClick = onSelectSearch,
|
||||||
leadingContent = {},
|
leadingContent = {},
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ fun PlaybackPage(
|
||||||
|
|
||||||
val player = viewModel.player
|
val player = viewModel.player
|
||||||
val mediaInfo by viewModel.currentMediaInfo.observeAsState()
|
val mediaInfo by viewModel.currentMediaInfo.observeAsState()
|
||||||
|
val userDto by viewModel.currentUserDto.observeAsState()
|
||||||
|
|
||||||
val currentPlayback by viewModel.currentPlayback.collectAsState()
|
val currentPlayback by viewModel.currentPlayback.collectAsState()
|
||||||
val currentItemPlayback by viewModel.currentItemPlayback.observeAsState(
|
val currentItemPlayback by viewModel.currentItemPlayback.observeAsState(
|
||||||
|
|
@ -561,6 +562,8 @@ fun PlaybackPage(
|
||||||
playbackSpeed = playbackSpeed,
|
playbackSpeed = playbackSpeed,
|
||||||
contentScale = contentScale,
|
contentScale = contentScale,
|
||||||
subtitleDelay = subtitleDelay,
|
subtitleDelay = subtitleDelay,
|
||||||
|
hasSubtitleDownloadPermission =
|
||||||
|
remember(userDto) { userDto?.policy?.let { it.isAdministrator || it.enableSubtitleManagement } == true },
|
||||||
),
|
),
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
playbackDialog = null
|
playbackDialog = null
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,8 @@ class PlaybackViewModel
|
||||||
val subtitleSearch = MutableLiveData<SubtitleSearch?>(null)
|
val subtitleSearch = MutableLiveData<SubtitleSearch?>(null)
|
||||||
val subtitleSearchLanguage = MutableLiveData<String>(Locale.current.language)
|
val subtitleSearchLanguage = MutableLiveData<String>(Locale.current.language)
|
||||||
|
|
||||||
|
val currentUserDto = serverRepository.currentUserDto
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addCloseable {
|
addCloseable {
|
||||||
player.removeListener(this@PlaybackViewModel)
|
player.removeListener(this@PlaybackViewModel)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue