1
0
Fork 0
pdsman-ios/PDSMan/Models/PDSModels.swift
2025-03-19 01:25:06 -06:00

68 lines
No EOL
1.5 KiB
Swift

import Foundation
// Credentials for connecting to the PDS
struct PDSCredentials: Sendable {
var serverURL: String
var username: String
var password: String
init?(serverURL: String, username: String, password: String) {
// Validate inputs
guard !serverURL.isEmpty, !username.isEmpty, !password.isEmpty else {
return nil
}
self.serverURL = serverURL
self.username = username
self.password = password
}
}
// Invite code model
struct InviteCode: Identifiable, Sendable {
var id: String
var code: String { id } // For compatibility with the view
var uses: [CodeUse]?
var createdAt: Date
var disabled: Bool
var isDisabled: Bool { disabled } // For backwards compatibility
}
// Invite use model
struct CodeUse: Codable, Identifiable, Sendable {
var id: String { usedBy }
var usedBy: String
var usedAt: String
}
// User model
struct PDSUser: Identifiable, Hashable, Sendable {
var id: String // DID
var handle: String
var displayName: String
var description: String
var joinedAt: Date
var avatar: URL?
var isActive: Bool = true
// Add Hashable conformance
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
static func == (lhs: PDSUser, rhs: PDSUser) -> Bool {
lhs.id == rhs.id
}
}
// Auth state
enum AuthState: Sendable {
case loggedOut
case loggedIn
}
// View state
enum ViewTab: Sendable {
case inviteCodes
case userList
}