Priv
This commit is contained in:
68
PDSMan/Models/PDSModels.swift
Normal file
68
PDSMan/Models/PDSModels.swift
Normal file
@ -0,0 +1,68 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user