mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
fixed search frequency
This commit is contained in:
parent
eb9582f07a
commit
0160564378
4 changed files with 9 additions and 15 deletions
|
|
@ -17,10 +17,8 @@ class DropManager {
|
|||
private init() {}
|
||||
|
||||
func showDrop(title: String, subtitle: String, duration: TimeInterval, icon: UIImage?) {
|
||||
// Add to queue
|
||||
notificationQueue.append((title: title, subtitle: subtitle, duration: duration, icon: icon))
|
||||
|
||||
// Process queue if not already processing
|
||||
if !isProcessingQueue {
|
||||
processQueue()
|
||||
}
|
||||
|
|
@ -33,11 +31,8 @@ class DropManager {
|
|||
}
|
||||
|
||||
isProcessingQueue = true
|
||||
|
||||
// Get the next notification
|
||||
let notification = notificationQueue.removeFirst()
|
||||
|
||||
// Show the notification
|
||||
let drop = Drop(
|
||||
title: notification.title,
|
||||
subtitle: notification.subtitle,
|
||||
|
|
@ -48,7 +43,6 @@ class DropManager {
|
|||
|
||||
Drops.show(drop)
|
||||
|
||||
// Schedule next notification
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + notification.duration) { [weak self] in
|
||||
self?.processQueue()
|
||||
}
|
||||
|
|
@ -69,9 +63,7 @@ class DropManager {
|
|||
showDrop(title: "Info", subtitle: message, duration: duration, icon: icon)
|
||||
}
|
||||
|
||||
// Method for handling download notifications with accurate status determination
|
||||
func downloadStarted(episodeNumber: Int) {
|
||||
// Use the JSController method to accurately determine if download will start immediately
|
||||
let willStartImmediately = JSController.shared.willDownloadStartImmediately()
|
||||
|
||||
let message = willStartImmediately
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ struct EnhancedActiveDownloadCard: View {
|
|||
}
|
||||
.padding(16)
|
||||
|
||||
if download != download { // Not last item (placeholder condition)
|
||||
if download != download {
|
||||
Divider()
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct SearchView: View {
|
|||
@State private var searchHistory: [String] = []
|
||||
@State private var isSearchFieldFocused = false
|
||||
@State private var saveDebounceTimer: Timer?
|
||||
@State private var searchDebounceTimer: Timer?
|
||||
|
||||
private let columns = [GridItem(.adaptive(minimum: 150))]
|
||||
|
||||
|
|
@ -142,17 +143,22 @@ struct SearchView: View {
|
|||
}
|
||||
}
|
||||
.onChange(of: searchQuery) { newValue in
|
||||
searchDebounceTimer?.invalidate()
|
||||
|
||||
if newValue.isEmpty {
|
||||
saveDebounceTimer?.invalidate()
|
||||
searchItems = []
|
||||
hasNoResults = false
|
||||
isSearching = false
|
||||
} else {
|
||||
performSearch()
|
||||
searchDebounceTimer = Timer.scheduledTimer(withTimeInterval: 0.7, repeats: false) { _ in
|
||||
performSearch()
|
||||
}
|
||||
|
||||
saveDebounceTimer?.invalidate()
|
||||
saveDebounceTimer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { _ in
|
||||
self.addToSearchHistory(newValue)}
|
||||
self.addToSearchHistory(newValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,18 +48,15 @@ struct SearchHistoryRow: View {
|
|||
|
||||
var body: some View {
|
||||
HStack {
|
||||
// Clock Icon
|
||||
Image(systemName: "clock")
|
||||
.frame(width: 24, height: 24)
|
||||
.foregroundStyle(Color.primary)
|
||||
|
||||
// Search Text
|
||||
Text(text)
|
||||
.foregroundStyle(Color.primary)
|
||||
|
||||
Spacer()
|
||||
|
||||
// Delete Button
|
||||
Button(action: onDelete) {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundStyle(Color.secondary)
|
||||
|
|
@ -70,7 +67,6 @@ struct SearchHistoryRow: View {
|
|||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onTap)
|
||||
|
||||
// Divider if needed
|
||||
if showDivider {
|
||||
Divider()
|
||||
.padding(.horizontal, 16)
|
||||
|
|
|
|||
Loading…
Reference in a new issue