Files
Termind/Frameworks/TermindApplication/FeatureModels/SnippetTimestamp.swift
T
Kaede Akino b3066afe77 feat(snippets): share cards and add color selection
Reuse card content across macOS and iOS with platform-sized icons and matching card heights. Add the shared Color field below Package and preserve selection, drag, and execution behavior.

Migrate stored snippets to V51 and write color in Vault V2 while retaining V1 decoding and guarding against lossy V1 writes.

Validation: macOS focused snippet, migration, architecture, and localization tests pass; 30 iOS focused tests pass; Swift format and localization checks pass. Full macOS testing also reports failures in unchanged KeyExport, MCP, and Agent suites.
2026-10-04 12:25:52 +08:00

20 lines
719 B
Swift

import Foundation
import TermindDomain
public enum SnippetTimestamp {
// Preserve the original iOS preference key so existing fallback dates survive upgrades.
private static let fallbackKey = "mobile.snippets.baselineModifiedAtFallback.v1"
public static func fallback(in defaults: UserDefaults?) -> Date {
if let existing = defaults?.object(forKey: fallbackKey) as? Date { return existing }
let date = Date()
defaults?.set(date, forKey: fallbackKey)
return date
}
public static func resolve(modifiedAt: Date?, fallback: Date) -> Date {
guard let modifiedAt, modifiedAt > VaultVersion.baselineDate else { return fallback }
return modifiedAt
}
}