aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-11-10 21:00:43 -0800
committerDustin Mierau <dustin@mierau.me>2025-11-10 21:00:43 -0800
commitddb9c69b24a67ac140af9ff20f5c36bdef6fb51b (patch)
tree0bb994f1ac7a608c90b33c402629b0c8b21caff4 /Hotline/Models
parenta4263aea6e2875fa77783685985e5c8f7991337f (diff)
Remove "New" suffix from our transfer clients. Further cleanup. Allow previewing certain files with HFS types (but no extensions). Cleanup preview files when window closes.
Diffstat (limited to 'Hotline/Models')
-rw-r--r--Hotline/Models/FileInfo.swift10
-rw-r--r--Hotline/Models/PreviewFileInfo.swift3
2 files changed, 11 insertions, 2 deletions
diff --git a/Hotline/Models/FileInfo.swift b/Hotline/Models/FileInfo.swift
index e3081c4..a2f0ea5 100644
--- a/Hotline/Models/FileInfo.swift
+++ b/Hotline/Models/FileInfo.swift
@@ -49,13 +49,19 @@ import UniformTypeIdentifiers
var children: [FileInfo]? = nil
var isPreviewable: Bool {
- let fileExtension = (self.name as NSString).pathExtension.lowercased()
+ var fileExtension = (self.name as NSString).pathExtension.lowercased()
+ if fileExtension.isEmpty && !self.type.isEmpty {
+ let type = self.type.lowercased()
+ if let ext = FileManager.HFSTypeToExtension[type] {
+ fileExtension = ext
+ }
+ }
+
if let fileType = UTType(filenameExtension: fileExtension) {
if fileType.canBePreviewedByQuickLook {
return true
}
- print("FILE TYPE?", fileType, fileExtension, fileType.isSubtype(of: .pdf), fileType.isSupertype(of: .pdf))
if fileType.isSubtype(of: .image) {
return true
}
diff --git a/Hotline/Models/PreviewFileInfo.swift b/Hotline/Models/PreviewFileInfo.swift
index dcf5314..7e05a97 100644
--- a/Hotline/Models/PreviewFileInfo.swift
+++ b/Hotline/Models/PreviewFileInfo.swift
@@ -7,6 +7,9 @@ struct PreviewFileInfo: Identifiable, Codable {
var size: Int
var name: String
+ var type: String? = nil
+ var creator: String? = nil
+
var previewType: FilePreviewType {
let fileExtension = (self.name as NSString).pathExtension
if let fileType = UTType(filenameExtension: fileExtension) {