Delay speech preload so web loads faster

This commit is contained in:
Jackson Harper 2024-03-29 10:25:35 +08:00
parent 2c6c8c0281
commit c70c4107f6

View file

@ -405,10 +405,14 @@ struct WebReaderContainerView: View {
anchorIndex: Int(item.readingProgressAnchor),
force: false
)
Task {
await audioController.preload(itemIDs: [item.unwrappedID])
}
viewModel.trackReadEvent(item: item)
// Wait 1.5s while loading the reader before attempting to preload the speech file
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1500)) {
Task {
await audioController.preload(itemIDs: [item.unwrappedID])
}
}
}
.confirmationDialog(linkToOpen?.absoluteString ?? "", isPresented: $displayLinkSheet,
titleVisibility: .visible) {