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:
Ray 2026-01-11 13:21:02 -05:00 committed by GitHub
parent ed67e5575f
commit 2377a15611
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -53,6 +53,7 @@ data class PlaybackSettings(
val playbackSpeed: Float,
val contentScale: ContentScale,
val subtitleDelay: Duration,
val hasSubtitleDownloadPermission: Boolean,
)
@Composable
@ -96,6 +97,7 @@ fun PlaybackDialog(
SubtitleChoiceBottomDialog(
choices = settings.subtitleStreams,
currentChoice = settings.subtitleIndex,
hasDownloadPermission = settings.hasSubtitleDownloadPermission,
onDismissRequest = {
onControllerInteraction.invoke()
onDismissRequest.invoke()
@ -275,6 +277,7 @@ fun SubtitleChoiceBottomDialog(
onSelectChoice: (Int) -> Unit,
onSelectSearch: () -> Unit,
gravity: Int,
hasDownloadPermission: Boolean,
currentChoice: Int? = null,
) {
// TODO enforcing a width ends up ignore the gravity
@ -366,6 +369,7 @@ fun SubtitleChoiceBottomDialog(
HorizontalDivider()
ListItem(
selected = false,
enabled = hasDownloadPermission,
onClick = onSelectSearch,
leadingContent = {},
headlineContent = {

View file

@ -130,6 +130,7 @@ fun PlaybackPage(
val player = viewModel.player
val mediaInfo by viewModel.currentMediaInfo.observeAsState()
val userDto by viewModel.currentUserDto.observeAsState()
val currentPlayback by viewModel.currentPlayback.collectAsState()
val currentItemPlayback by viewModel.currentItemPlayback.observeAsState(
@ -561,6 +562,8 @@ fun PlaybackPage(
playbackSpeed = playbackSpeed,
contentScale = contentScale,
subtitleDelay = subtitleDelay,
hasSubtitleDownloadPermission =
remember(userDto) { userDto?.policy?.let { it.isAdministrator || it.enableSubtitleManagement } == true },
),
onDismissRequest = {
playbackDialog = null

View file

@ -168,6 +168,8 @@ class PlaybackViewModel
val subtitleSearch = MutableLiveData<SubtitleSearch?>(null)
val subtitleSearchLanguage = MutableLiveData<String>(Locale.current.language)
val currentUserDto = serverRepository.currentUserDto
init {
addCloseable {
player.removeListener(this@PlaybackViewModel)