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 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 = {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue