Skip to content

Commit a165444

Browse files
authored
Fix crash adding new server with scene actions (#1943)
Fixes regression from #1941. ## Summary The default value of `.max` isn't adjusted to a real one until after onboarding is finished, but we do a model fetch _during_ onboarding to test that it works.
1 parent 8a6a48f commit a165444

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Sources/Shared/API/Server.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public struct ServerInfo: Codable, Equatable {
6767
version: Version
6868
) {
6969
self.name = name
70-
self.sortOrder = .max
70+
self.sortOrder = Self.defaultSortOrder
7171
self.connection = connection
7272
self.token = token
7373
self.version = version
@@ -78,6 +78,8 @@ public struct ServerInfo: Codable, Equatable {
7878
L10n.Settings.StatusSection.LocationNameRow.placeholder
7979
}
8080

81+
public static var defaultSortOrder: Int { -1 }
82+
8183
public mutating func setSetting<T>(value: T?, for key: ServerSettingKey<T>) {
8284
settings[key.rawValue] = value
8385
}

Sources/Shared/API/ServerManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ internal final class ServerManagerImpl: ServerManager {
184184
@discardableResult
185185
public func add(identifier: Identifier<Server>, serverInfo: ServerInfo) -> Server {
186186
let setValue = with(serverInfo) {
187-
if $0.sortOrder == .max {
187+
if $0.sortOrder == ServerInfo.defaultSortOrder {
188188
$0.sortOrder = all.map(\.info.sortOrder).max().map { $0 + 1000 } ?? 0
189189
}
190190
}

0 commit comments

Comments
 (0)