macsync/@packages/imessage/Sources/IMessageSync/ModuleAccessors.swift

36 lines
1.1 KiB
Swift
Raw Normal View History

import Foundation
/// Public MainActor-bound accessors for IMessageSync module singletons.
///
/// Since `SyncManager` is an internal type (not public), MacSyncApp can't reference
/// `IMessageSync.SyncManager.shared` directly. These @MainActor static wrappers expose
/// the interface MacSyncApp needs without leaking the internal type.
@MainActor
public enum IMessageSyncModule {
/// Start the iMessage sync cycle. Delegates to the internal SyncManager.
public static func startSync() {
SyncManager.shared.startSync()
}
/// Trigger an immediate sync cycle. Delegates to the internal SyncManager.
public static func syncNow() {
SyncManager.shared.syncNow()
}
/// Whether a sync is currently in progress.
public static var isSyncing: Bool {
SyncManager.shared.isSyncing
}
/// Date of the last completed sync cycle.
public static var lastSyncCompletedAt: Date? {
SyncManager.shared.lastSyncCompletedAt
}
/// Current sync error message, empty string if none.
public static var syncErrorMessage: String {
SyncManager.shared.syncError.message
}
}