mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Handle ios out of bounds issue
This commit is contained in:
parent
52ad191255
commit
135feeb362
1 changed files with 9 additions and 7 deletions
|
|
@ -411,13 +411,15 @@
|
|||
currentItemOffset = max(currentItemOffset, 0)
|
||||
|
||||
let idx = currentAudioIndex // item.speechItem.audioIdx
|
||||
let currentItem = document?.utterances[idx].text ?? ""
|
||||
let currentReadIndex = currentItem.index(currentItem.startIndex, offsetBy: min(currentItemOffset, currentItem.count))
|
||||
let lastItem = String(currentItem[..<currentReadIndex])
|
||||
let lastItemAfter = String(currentItem[currentReadIndex...])
|
||||
|
||||
readText = lastItem
|
||||
unreadText = lastItemAfter
|
||||
if idx < document?.utterances.count ?? 0 {
|
||||
let currentItem = document?.utterances[idx].text ?? ""
|
||||
let currentReadIndex = currentItem.index(currentItem.startIndex, offsetBy: min(currentItemOffset, currentItem.count))
|
||||
let lastItem = String(currentItem[..<currentReadIndex])
|
||||
let lastItemAfter = String(currentItem[currentReadIndex...])
|
||||
|
||||
readText = lastItem
|
||||
unreadText = lastItemAfter
|
||||
}
|
||||
} else {
|
||||
readText = ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue