Private
Public Access
1
0
Files
Kordophone/kordophone2/App.swift

45 lines
1.1 KiB
Swift
Raw Normal View History

2025-08-24 16:24:21 -07:00
//
// kordophone2App.swift
// kordophone2
//
// Created by James Magahern on 8/24/25.
//
import SwiftUI
@main
struct KordophoneApp: App
{
@State var conversationListModel = ConversationListView.ViewModel()
private let xpcClient = XPCClient()
var body: some Scene {
WindowGroup {
NavigationSplitView {
ConversationListView(model: $conversationListModel)
.frame(minWidth: 330.0)
.task {
await refreshConversations()
}
} detail: {
// Detail
}
}
}
private func refreshConversations() async {
do {
let conversations = try await xpcClient.getConversations()
conversationListModel.conversations = conversations.map { Display.Conversation(from: $0) }
} catch {
reportError(error)
}
}
private func reportError(_ e: Error) {
// Just printing for now.
print("Error: \(e.localizedDescription)")
}
}