Files
Lichtkasten DevandClaude Opus 5.5 223d8b0610 Bilder per Drag & Drop verschieben, neue Ordner anlegen
- Bilder aus dem Kontaktabzug auf einen Ordner in der Seitenleiste ziehen = verschieben (ganze Auswahl,
  RAW + JPEG + XMP zusammen, Namenskollision → -1, Gesendet-Status zieht mit, alles-oder-nichts pro Bild)
- aus dem Finder gezogene Bilder werden in den Ordner kopiert
- Ordner hebt sich beim Darüberziehen hervor, Vorschau mit Anzahl unter dem Zeiger
- „Neuer Ordner …“ per Rechtsklick auf jeden Ordner, Knopf bei Favoriten legt ihn in INPUT an
  (Name mit heutigem Datum vorbelegt), danach wird er geöffnet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
2026-11-08 17:47:22 +00:00

111 lines
4.7 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
/// One successful upload of a file.
public struct SentRecord: Codable, Hashable, Sendable {
/// FTP destination id (uuid string) or "immich"
public var destination: String
/// Destination name at the time of sending ("Beautiful Sports – Sport")
public var destinationName: String
/// File name on the server (after renaming)
public var remoteName: String
public var date: Date
public var size: Int64
public init(destination: String, destinationName: String, remoteName: String, date: Date = Date(), size: Int64 = 0) {
self.destination = destination; self.destinationName = destinationName
self.remoteName = remoteName; self.date = date; self.size = size
}
}
/// Upload history per file ("Gesendet"-Status). Keyed by the standardized file path; a photo counts as sent
/// when any of its files (RAW, JPEG companion) was sent.
public struct SentLog: Codable, Sendable {
public private(set) var records: [String: [SentRecord]] = [:]
public init() {}
public static func key(_ url: URL) -> String { url.standardizedFileURL.path }
public mutating func record(_ url: URL, _ r: SentRecord) {
records[SentLog.key(url), default: []].append(r)
}
/// A file was moved (drag & drop into another folder) – its history moves with it.
public mutating func move(from old: URL, to new: URL) {
guard let r = records.removeValue(forKey: SentLog.key(old)) else { return }
records[SentLog.key(new), default: []].append(contentsOf: r)
}
/// Forget the history of these files ("Als nicht gesendet markieren").
public mutating func clear(_ urls: [URL]) {
for u in urls { records[SentLog.key(u)] = nil }
}
public func records(for urls: [URL]) -> [SentRecord] {
urls.flatMap { records[SentLog.key($0)] ?? [] }.sorted { $0.date < $1.date }
}
public func records(for item: PhotoItem) -> [SentRecord] {
records(for: [item.primary] + item.companions)
}
public func wasSent(_ item: PhotoItem, to destination: String? = nil) -> Bool {
let r = records(for: item)
guard let destination else { return !r.isEmpty }
return r.contains { $0.destination == destination }
}
/// Short summary for the thumbnail / panels, newest first.
public func summary(for item: PhotoItem) -> SentSummary? {
let r = records(for: item)
guard let last = r.last else { return nil }
let names = r.reduce(into: [String]()) { acc, rec in if !acc.contains(rec.destinationName) { acc.append(rec.destinationName) } }
var s = SentSummary(count: r.count, destinations: names, last: last.date, lastDestination: last.destinationName)
let ftp = r.filter { $0.destination != SentLog.immich }, immich = r.filter { $0.destination == SentLog.immich }
s.ftp = ftp.last.map { SentSummary.Part(count: ftp.count, last: $0.date,
destinations: Array(Set(ftp.map(\.destinationName))).sorted()) }
s.immich = immich.last.map { SentSummary.Part(count: immich.count, last: $0.date, destinations: ["Immich"]) }
return s
}
public static let immich = "immich"
/// Sent to an FTP server (any) / to Immich.
public func wasSentByFTP(_ item: PhotoItem) -> Bool { records(for: item).contains { $0.destination != SentLog.immich } }
public func wasSentToImmich(_ item: PhotoItem) -> Bool { records(for: item).contains { $0.destination == SentLog.immich } }
}
public struct SentSummary: Hashable, Sendable {
public var count: Int
public var destinations: [String]
public var last: Date
public var lastDestination: String
/// FTP and Immich separately – two badges on the thumbnail
public var ftp: Part?
public var immich: Part?
public struct Part: Hashable, Sendable {
public var count: Int
public var last: Date
public var destinations: [String]
public var tooltip: String {
let f = DateFormatter()
f.dateFormat = "dd.MM.yyyy HH:mm"
let times = count == 1 ? "" : " (\(count)× gesendet)"
return "Gesendet an \(destinations.joined(separator: ", ")) – zuletzt \(f.string(from: last))\(times)"
}
}
public init(count: Int, destinations: [String], last: Date, lastDestination: String) {
self.count = count; self.destinations = destinations; self.last = last; self.lastDestination = lastDestination
}
public var tooltip: String {
let f = DateFormatter()
f.dateFormat = "dd.MM.yyyy HH:mm"
let times = count == 1 ? "" : " (\(count)× gesendet)"
return "Gesendet an \(destinations.joined(separator: ", ")) – zuletzt \(f.string(from: last))\(times)"
}
}