Enforce user locks for AI updates
This commit is contained in:
@@ -23,6 +23,7 @@ public struct SongProject: Codable, Equatable, Identifiable, Sendable {
|
||||
public var lyrics: Lyrics
|
||||
public var productionDirections: [ProductionDirection]
|
||||
public var productionMode: ControlMode?
|
||||
public var userLocks: SongProjectUserLocks?
|
||||
public var sunoOutput: SunoOutput?
|
||||
public var versions: [SongVersion]
|
||||
public let createdAt: Date
|
||||
@@ -51,6 +52,7 @@ public struct SongProject: Codable, Equatable, Identifiable, Sendable {
|
||||
lyrics: Lyrics = Lyrics(),
|
||||
productionDirections: [ProductionDirection] = [],
|
||||
productionMode: ControlMode? = .auto,
|
||||
userLocks: SongProjectUserLocks? = SongProjectUserLocks(),
|
||||
sunoOutput: SunoOutput? = nil,
|
||||
versions: [SongVersion] = [],
|
||||
createdAt: Date = Date(),
|
||||
@@ -78,6 +80,7 @@ public struct SongProject: Codable, Equatable, Identifiable, Sendable {
|
||||
self.lyrics = lyrics
|
||||
self.productionDirections = productionDirections
|
||||
self.productionMode = productionMode
|
||||
self.userLocks = userLocks
|
||||
self.sunoOutput = sunoOutput
|
||||
self.versions = versions
|
||||
self.createdAt = createdAt
|
||||
@@ -102,6 +105,26 @@ public extension SongProject {
|
||||
productionMode = mode
|
||||
}
|
||||
|
||||
var lockedUpdateScopes: [SongProjectUpdateScope] {
|
||||
userLocks?.scopes ?? []
|
||||
}
|
||||
|
||||
func isUpdateScopeLocked(_ scope: SongProjectUpdateScope) -> Bool {
|
||||
userLocks?.contains(scope) ?? false
|
||||
}
|
||||
|
||||
mutating func lockUpdateScope(_ scope: SongProjectUpdateScope) {
|
||||
var userLocks = userLocks ?? SongProjectUserLocks()
|
||||
userLocks.insert(scope)
|
||||
self.userLocks = userLocks
|
||||
}
|
||||
|
||||
mutating func unlockUpdateScope(_ scope: SongProjectUpdateScope) {
|
||||
guard var userLocks else { return }
|
||||
userLocks.remove(scope)
|
||||
self.userLocks = userLocks
|
||||
}
|
||||
|
||||
var orderedSections: [SongSection] {
|
||||
sections
|
||||
.enumerated()
|
||||
@@ -393,6 +416,7 @@ public extension SongProject {
|
||||
lyrics = snapshot.lyrics
|
||||
productionDirections = snapshot.productionDirections
|
||||
productionMode = snapshot.productionMode
|
||||
userLocks = snapshot.userLocks
|
||||
sunoOutput = snapshot.sunoOutput
|
||||
self.updatedAt = updatedAt
|
||||
}
|
||||
@@ -795,6 +819,7 @@ public struct SongProjectSnapshot: Codable, Equatable, Sendable {
|
||||
public var lyrics: Lyrics
|
||||
public var productionDirections: [ProductionDirection]
|
||||
public var productionMode: ControlMode?
|
||||
public var userLocks: SongProjectUserLocks?
|
||||
public var sunoOutput: SunoOutput?
|
||||
|
||||
public init(
|
||||
@@ -819,6 +844,7 @@ public struct SongProjectSnapshot: Codable, Equatable, Sendable {
|
||||
lyrics: Lyrics = Lyrics(),
|
||||
productionDirections: [ProductionDirection] = [],
|
||||
productionMode: ControlMode? = .auto,
|
||||
userLocks: SongProjectUserLocks? = SongProjectUserLocks(),
|
||||
sunoOutput: SunoOutput? = nil
|
||||
) {
|
||||
self.title = title
|
||||
@@ -842,6 +868,7 @@ public struct SongProjectSnapshot: Codable, Equatable, Sendable {
|
||||
self.lyrics = lyrics
|
||||
self.productionDirections = productionDirections
|
||||
self.productionMode = productionMode
|
||||
self.userLocks = userLocks
|
||||
self.sunoOutput = sunoOutput
|
||||
}
|
||||
|
||||
@@ -868,6 +895,7 @@ public struct SongProjectSnapshot: Codable, Equatable, Sendable {
|
||||
lyrics: project.lyrics,
|
||||
productionDirections: project.productionDirections,
|
||||
productionMode: project.productionMode,
|
||||
userLocks: project.userLocks,
|
||||
sunoOutput: project.sunoOutput
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user