-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
got smarter search, async stuff, lazy load thumbnails, infinite scrolling #25
Conversation
|
do { | ||
for row in try db.prepare(query) { | ||
let frameId = row[allText[frameId]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
value.forEach { v in | ||
offsetToId[v.1] = v.0 | ||
} | ||
let imageSequence = DatabaseManager.shared.getImages(filePath: key, frameOffsets: frameOffsets, maxSize: CGSize(width: 600, height: 600)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batched async retrieval, which calls updateThumbnail
on published thumbnail
for that sweet async update
debounceTimer?.invalidate() | ||
analyzeImage(image) | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting rid of this should fix a lot of issues due to all kinds of logic happening in CustomHostingControllerRepresentable
like binding keys for quitting...
@@ -307,8 +326,8 @@ class TimelineViewModel: ObservableObject { | |||
} | |||
|
|||
func updateIndexSafely() { | |||
let rounded = Int64(currentFrameContinuous) | |||
if DatabaseManager.shared.getFrame(forIndex: rounded) != nil { | |||
indexUpdateThrottle.throttle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throttling for stability...
DispatchQueue.main.async { | ||
self.searchViewWindow?.orderFrontRegardless() // Ensure it comes to the front | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
someone explain main thread / ui thread in relation to dispatchqueue to me please
.onScrollToBottom { | ||
Task { | ||
loadMoreResults() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger infinite load
@@ -56,8 +57,7 @@ struct SearchBar: View { | |||
} | |||
} // Trigger search when user submits | |||
.onChange(of: text) { | |||
debounceTimer?.invalidate() | |||
debounceTimer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: false) { _ in | |||
debounceSearch.debounce { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better
let aI = try generator.copyCGImage(at: a, actualTime: nil) | ||
return aI | ||
} catch { | ||
print("Error extracting frame \(videoURL): \(error)") | ||
return nil | ||
} | ||
} | ||
|
||
func extractFrames(from videoURL: URL, frameOffsets: [Int64], maxSize: CGSize? = nil) -> AVAssetImageGenerator.Images { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batch retrieval. so really we should be doing this in timeline too, but #7 should be much more easily solvable with this. "are we near a new chunk? load the whole thing"
if !FileManager.default.fileExists(atPath: videoURL.path) { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg file io ON EVERY SINGLE SEARCH RESULT
someone else take over this project
I shouldn't have stayed up all night BUT
scrolling.mp4