continue fixing
This commit is contained in:
@@ -627,6 +627,15 @@ struct RootView: View {
|
||||
return "暂无中文字幕"
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func applyChineseTranslations(_ map: [Int: String], mediaId: String) {
|
||||
guard controller.currentItem?.id == mediaId else { return }
|
||||
let updated = (controller.currentItem?.sentences ?? []).map { sentence in
|
||||
sentence.withZhText(map[sentence.index] ?? sentence.zhText)
|
||||
}
|
||||
controller.updateBoundaries(updated)
|
||||
}
|
||||
|
||||
private func ensureChineseTranslations() {
|
||||
guard showChineseSubtitles, activeModule == .train else {
|
||||
return
|
||||
@@ -656,14 +665,14 @@ struct RootView: View {
|
||||
let map = try await SentenceBoundaryAPI.loadSubtitles(
|
||||
videoHash: mediaId,
|
||||
expectedIndexes: expectedIndexes
|
||||
)
|
||||
) { partial in
|
||||
Task { @MainActor in
|
||||
applyChineseTranslations(partial, mediaId: mediaId)
|
||||
}
|
||||
}
|
||||
guard !Task.isCancelled else { return }
|
||||
await MainActor.run {
|
||||
guard controller.currentItem?.id == mediaId else { return }
|
||||
let updated = (controller.currentItem?.sentences ?? []).map { sentence in
|
||||
sentence.withZhText(map[sentence.index] ?? sentence.zhText)
|
||||
}
|
||||
controller.updateBoundaries(updated)
|
||||
applyChineseTranslations(map, mediaId: mediaId)
|
||||
chineseTranslationLoading = false
|
||||
chineseTranslationError = ""
|
||||
controller.showTransientMessage("已加载中文字幕")
|
||||
|
||||
Reference in New Issue
Block a user