@@ -670,7 +670,7 @@ fun PlayerOverlay(
670670
671671 val refreshSubtitleList =
672672 remember(playerViewModel, userInfoViewModel, streamViewModel, subtitleDeleteState) {
673- {
673+ { targetTrimId : String? ->
674674 val cache = playerViewModel.playingInfoCache.value
675675 if (cache != null ) {
676676 kotlinx.coroutines.CoroutineScope (kotlinx.coroutines.Dispatchers .Main ).launch {
@@ -698,6 +698,17 @@ fun PlayerOverlay(
698698 playerViewModel.updateSubtitleList(
699699 streamResponse.subtitleStreams ? : emptyList(), streamResponse
700700 )
701+ if (targetTrimId != null ) {
702+ val targetSubtitle =
703+ streamResponse.subtitleStreams?.find { it.trimId == targetTrimId }
704+ if (targetSubtitle != null ) {
705+ playerViewModel.updatePlayingInfo(
706+ playerViewModel.playingInfoCache.value?.copy(
707+ currentSubtitleStream = targetSubtitle
708+ )
709+ )
710+ }
711+ }
701712 }
702713 } catch (e: Exception ) {
703714 logger.e(" Failed to refresh subtitle list" , e)
@@ -709,14 +720,14 @@ fun PlayerOverlay(
709720
710721 LaunchedEffect (subtitleDeleteState) {
711722 if (subtitleDeleteState is UiState .Success ) {
712- refreshSubtitleList()
723+ refreshSubtitleList(null )
713724 subtitleDeleteViewModel.clearError()
714725 }
715726 }
716727
717728 LaunchedEffect (subtitleUploadState) {
718729 if (subtitleUploadState is UiState .Success ) {
719- refreshSubtitleList()
730+ refreshSubtitleList(null )
720731 subtitleUploadViewModel.clearError()
721732 }
722733 }
@@ -2497,7 +2508,7 @@ fun PlayerDialogs(
24972508 playingInfoCache : PlayingInfoCache ? ,
24982509 subtitleToDelete : SubtitleStream ? ,
24992510 onSubtitleDeleteConfirm : () -> Unit ,
2500- refreshSubtitleList : () -> Unit
2511+ refreshSubtitleList : (String? ) -> Unit
25012512) {
25022513 if (showSubtitleSearchDialog) {
25032514 val mediaGuid = playingInfoCache?.currentFileStream?.guid ? : " "
@@ -2512,8 +2523,8 @@ fun PlayerDialogs(
25122523 trimIdList = trimIdList,
25132524 mediaFileName = mediaFileName,
25142525 onDismissRequest = onSubtitleSearchDialogDismiss,
2515- onSubtitleDownloadSuccess = {
2516- refreshSubtitleList()
2526+ onSubtitleDownloadSuccess = { trimId ->
2527+ refreshSubtitleList(trimId )
25172528 }
25182529 )
25192530 }
@@ -2530,7 +2541,7 @@ fun PlayerDialogs(
25302541 onButtonClick = { button, paths ->
25312542 if (button == ContentDialogButton .Primary && ! paths.isNullOrEmpty()) {
25322543 subtitleMarkViewModel.markSubtitles(mediaGuid, paths.toList())
2533- refreshSubtitleList()
2544+ refreshSubtitleList(null )
25342545 onAddNasSubtitleDialogDismiss()
25352546 } else if (button == ContentDialogButton .Close ) {
25362547 onAddNasSubtitleDialogDismiss()
0 commit comments