Add profile settings and permission models
This commit is contained in:
30
Yeti/Models/NostrClientModel.swift
Normal file
30
Yeti/Models/NostrClientModel.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// NostrClientModel.swift
|
||||
// Yeti
|
||||
//
|
||||
// Created by Terry Yiu on 1/20/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
@Model
|
||||
final class NostrClientModel {
|
||||
@Attribute(.unique) var id: String
|
||||
|
||||
@Relationship(deleteRule: .cascade) var signEventPermissions: [SignEventPermissionModel] = []
|
||||
|
||||
var signingPolicy: SigningPolicy?
|
||||
|
||||
var readPublicKeyPermission: Bool?
|
||||
var nip04EncryptPermission: Bool?
|
||||
var nip44EncryptPermission: Bool?
|
||||
var nip04DencryptPermission: Bool?
|
||||
var nip44DencryptPermission: Bool?
|
||||
var getRelaysPermission: Bool?
|
||||
var decryptZapEventPermission: Bool?
|
||||
|
||||
init(id: String) {
|
||||
self.id = id
|
||||
}
|
||||
}
|
||||
20
Yeti/Models/ProfileSettingsModel.swift
Normal file
20
Yeti/Models/ProfileSettingsModel.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// ProfileSettingsModel.swift
|
||||
// Yeti
|
||||
//
|
||||
// Created by Terry Yiu on 1/20/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
@Model
|
||||
final class ProfileSettingsModel {
|
||||
@Attribute(.unique) var publicKey: String
|
||||
|
||||
var nostrClientModels: [NostrClientModel] = []
|
||||
|
||||
init(publicKey: String) {
|
||||
self.publicKey = publicKey
|
||||
}
|
||||
}
|
||||
20
Yeti/Models/SignEventPermissionModel.swift
Normal file
20
Yeti/Models/SignEventPermissionModel.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SignEventPermissionModel.swift
|
||||
// Yeti
|
||||
//
|
||||
// Created by Terry Yiu on 1/20/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
@Model
|
||||
final class SignEventPermissionModel {
|
||||
var kind: Int
|
||||
var allowed: Bool
|
||||
|
||||
init(kind: Int, allowed: Bool) {
|
||||
self.kind = kind
|
||||
self.allowed = allowed
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,11 @@
|
||||
//
|
||||
// SigningPolicyModel.swift
|
||||
// SigningPolicy.swift
|
||||
// Yeti
|
||||
//
|
||||
// Created by Terry Yiu on 1/20/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
@Model
|
||||
final class SigningPolicyModel {
|
||||
var signingPolicy: SigningPolicy
|
||||
|
||||
init(signingPolicy: SigningPolicy) {
|
||||
self.signingPolicy = signingPolicy
|
||||
}
|
||||
}
|
||||
|
||||
enum SigningPolicy: Int, Codable, CaseIterable {
|
||||
case basic = 0
|
||||
@@ -19,5 +19,5 @@ struct ContentView: View {
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
.modelContainer(for: SigningPolicyModel.self, inMemory: true)
|
||||
.modelContainer(for: ProfileSettingsModel.self, inMemory: true)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct YetiApp: App {
|
||||
|
||||
var sharedModelContainer: ModelContainer = {
|
||||
let schema = Schema([
|
||||
SigningPolicyModel.self
|
||||
ProfileSettingsModel.self
|
||||
])
|
||||
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user