mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Update: CLI support
This commit is contained in:
parent
e95e5b0118
commit
f9fe2e363d
5 changed files with 29860 additions and 29801 deletions
|
|
@ -154,6 +154,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
func applicationDidBecomeActive(_ notification: Notification) {
|
||||
installTopMenuItemsIfNeeded()
|
||||
}
|
||||
|
||||
func application(_ application: NSApplication, open urls: [URL]) {
|
||||
_ = handleIncomingShelfURLs(urls)
|
||||
}
|
||||
|
||||
func application(_ sender: NSApplication, openFile filename: String) -> Bool {
|
||||
handleIncomingShelfURLs([URL(fileURLWithPath: filename)])
|
||||
}
|
||||
|
||||
private func handleIncomingShelfURLs(_ urls: [URL]) -> Bool {
|
||||
let fileURLs = urls.filter(\.isFileURL)
|
||||
guard !fileURLs.isEmpty else { return false }
|
||||
|
||||
Task { @MainActor [weak self] in
|
||||
let items = await ShelfDropService.items(from: fileURLs)
|
||||
guard !items.isEmpty else { return }
|
||||
|
||||
ShelfStateViewModel.shared.add(items)
|
||||
self?.coordinator.currentView = .shelf
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/// Setup observers for music player state changes to restart AudioTap capture
|
||||
private func setupAudioTapMusicObservers() {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -36,6 +36,26 @@ struct ShelfDropService {
|
|||
|
||||
return results
|
||||
}
|
||||
|
||||
static func items(from fileURLs: [URL]) async -> [ShelfItem] {
|
||||
var results: [ShelfItem] = []
|
||||
let fileManager = FileManager.default
|
||||
|
||||
for fileURL in fileURLs {
|
||||
let resolvedURL = fileURL.standardizedFileURL
|
||||
guard resolvedURL.isFileURL else { continue }
|
||||
guard fileManager.fileExists(atPath: resolvedURL.path) else {
|
||||
NSLog("⚠️ Ignoring non-existent file URL: \(resolvedURL.path)")
|
||||
continue
|
||||
}
|
||||
|
||||
if let bookmark = createBookmark(for: resolvedURL) {
|
||||
results.append(await ShelfItem(kind: .file(bookmark: bookmark), isTemporary: false))
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
private static func processProvider(_ provider: NSItemProvider) async -> ShelfItem? {
|
||||
if let actualFileURL = await provider.extractFileURL() {
|
||||
|
|
@ -81,4 +101,3 @@ struct ShelfDropService {
|
|||
return (try? Bookmark(url: url))?.data
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue