punchnet-macos/punchnet/AppEventCenter/SDLTunnelAppEventStore.swift

32 lines
890 B
Swift

//
// SDLTunnelAppEventStore.swift
// punchnet
//
// Created by on 2026/4/15.
//
import Foundation
struct SDLTunnelAppEventStore {
typealias Event = TunnelEvent
static func loadLatestEvent() -> Event? {
guard let shared = UserDefaults(suiteName: SDLNotificationCenter.Configuration.appGroupSuiteName),
let data = shared.data(forKey: SDLNotificationCenter.Configuration.latestEventKey),
let event = try? Event(serializedBytes: data) else {
return nil
}
return event
}
static func clearLatestEvent() {
guard let shared = UserDefaults(suiteName: SDLNotificationCenter.Configuration.appGroupSuiteName) else {
return
}
shared.removeObject(forKey: SDLNotificationCenter.Configuration.latestEventKey)
shared.synchronize()
}
}