Skip to content
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

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

jasonjmcghee
Copy link
Owner

I shouldn't have stayed up all night BUT

scrolling.mp4

@jasonjmcghee jasonjmcghee merged commit 7997696 into main Dec 30, 2023
@jasonjmcghee
Copy link
Owner Author

Timings.swift didn't make it in... pushed it to main

do {
for row in try db.prepare(query) {
let frameId = row[allText[frameId]]
Copy link
Owner Author

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))
Copy link
Owner Author

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 {
Copy link
Owner Author

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 {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throttling for stability...

Comment on lines +638 to +640
DispatchQueue.main.async {
self.searchViewWindow?.orderFrontRegardless() // Ensure it comes to the front
}
Copy link
Owner Author

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

Comment on lines +267 to +271
.onScrollToBottom {
Task {
loadMoreResults()
}
}
Copy link
Owner Author

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 {
Copy link
Owner Author

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 {
Copy link
Owner Author

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"

Comment on lines -265 to -267
if !FileManager.default.fileExists(atPath: videoURL.path) {
return nil
}
Copy link
Owner Author

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

@jasonjmcghee jasonjmcghee deleted the smarter-throttling branch December 30, 2023 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant