From ede41868962ffed386b0da694d14cdfe6cfdb34f Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Mon, 20 Oct 2025 22:15:48 -0700 Subject: Cleanup and a bunch of work to fix issues syncing, loading, and general bookmark states in TrackerView. Added search field (substring conjunctive filter on server/bookmark names and descriptions). --- Hotline/Library/DataAdditions.swift | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Hotline/Library/DataAdditions.swift (limited to 'Hotline/Library/DataAdditions.swift') diff --git a/Hotline/Library/DataAdditions.swift b/Hotline/Library/DataAdditions.swift new file mode 100644 index 0000000..0e9dd96 --- /dev/null +++ b/Hotline/Library/DataAdditions.swift @@ -0,0 +1,23 @@ +import Foundation + +extension Data { + func saveAsFileToDownloads(filename: String, bounceDock: Bool = true) -> Bool { + let folderURL = FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask)[0] + let filePath = folderURL.generateUniqueFilePath(filename: filename) + if FileManager.default.createFile(atPath: filePath, contents: nil) { + if let h = FileHandle(forWritingAtPath: filePath) { + try? h.write(contentsOf: self) + try? h.close() + if bounceDock { + #if os(macOS) + var downloadURL = URL(filePath: filePath) + downloadURL.resolveSymlinksInPath() + DistributedNotificationCenter.default().post(name: .init("com.apple.DownloadFileFinished"), object: downloadURL.path) + #endif + } + return true + } + } + return false + } +} -- cgit