mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 02:29:55 +02:00
refactor(apple): type core event phase/kind/direction as enums
Replaces the stringly-typed transfer-event phase/kind/direction values throughout the progress-derivation logic with EventPhase, EventKind and EventDirection enums (String-backed to match the core's wire values). CoreEventModel keeps the raw wire strings as a faithful boundary DTO but exposes typed eventPhase/eventKind/eventDirection accessors; all logic — progressForTransfer/Receiver, humanProgressLabel, aggregateReceiverProgress, the refresh trigger, and the SendScreen snapshots — now compares enum cases instead of literals. TransferProgress.phase/kind are the enums directly, so constructions read `phase: .transfer, kind: .progress`. The two ad-hoc phase/kind Sets collapse into "is a recognized case" (non-nil) checks.
This commit is contained in:
@@ -298,14 +298,15 @@ private extension CoreEvent {
|
||||
}
|
||||
}
|
||||
|
||||
private let refreshPhases: Set<String> = ["lifecycle", "error", "ticket", "import", "download", "export", "handshake"]
|
||||
private let refreshKinds: Set<String> = [
|
||||
"started", "done", "created", "failed", "cancelled", "share-stopped", "found-collection", "connected",
|
||||
private let refreshPhases: Set<EventPhase> = [.lifecycle, .error, .ticket, .importing, .download, .export, .handshake]
|
||||
private let refreshKinds: Set<EventKind> = [
|
||||
.started, .done, .created, .failed, .cancelled, .shareStopped, .foundCollection, .connected,
|
||||
]
|
||||
|
||||
private extension CoreEventModel {
|
||||
var shouldRefreshTransfers: Bool {
|
||||
refreshPhases.contains(phase) && refreshKinds.contains(kind)
|
||||
guard let eventPhase, let eventKind else { return false }
|
||||
return refreshPhases.contains(eventPhase) && refreshKinds.contains(eventKind)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user