Connect macOS app to backend device bootstrap
This commit is contained in:
@@ -36,28 +36,13 @@ public actor PlaceholderSyncCoordinator: SyncCoordinator {
|
||||
}
|
||||
|
||||
public func performInitialSync() async throws -> SyncResult {
|
||||
let health = try await apiClient.fetchHealthStatus()
|
||||
let existingTracks = await store.loadTracks()
|
||||
let tracks: [LibraryTrack]
|
||||
|
||||
if existingTracks.isEmpty {
|
||||
tracks = [
|
||||
LibraryTrack(
|
||||
title: "Velody Placeholder",
|
||||
artist: "Private Library",
|
||||
album: "Phase 1",
|
||||
localFilePath: ""
|
||||
),
|
||||
]
|
||||
await store.replaceTracks(tracks)
|
||||
} else {
|
||||
tracks = existingTracks
|
||||
}
|
||||
let bootstrap = try await apiClient.fetchSyncBootstrap()
|
||||
await store.replaceTracks(bootstrap.tracks)
|
||||
|
||||
return SyncResult(
|
||||
statusMessage: "Sync placeholder ready (\(health.databaseStatus)/\(health.storageStatus))",
|
||||
tracks: tracks,
|
||||
cursor: SyncCursor(value: "0")
|
||||
statusMessage: "Sync bootstrap completed. Tracks: \(bootstrap.tracks.count). Next cursor: \(bootstrap.nextCursor.value).",
|
||||
tracks: bootstrap.tracks,
|
||||
cursor: bootstrap.nextCursor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user