Optimization

This commit is contained in:
Lumaa 2024-03-24 00:24:24 +01:00
parent b1fa8904d9
commit 9c22373f9a
1 changed files with 6 additions and 7 deletions

View File

@ -69,15 +69,14 @@ class UserPreferences: Codable, ObservableObject {
return UserPreferences.defaultPreferences
}
// WARNINGS EVERYWHERE WHY...
required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.displayedName = try container.decode(DisplayedName.self, forKey: ._displayedName) ?? .username
self.profilePictureShape = try container.decode(ProfilePictureShape.self, forKey: ._profilePictureShape) ?? .circle
self.browserType = try container.decode(BrowserType.self, forKey: ._browserType) ?? .inApp
self.defaultVisibility = try container.decode(Visibility.self, forKey: ._defaultVisibility) ?? .pub
self.showExperimental = try container.decode(Bool.self, forKey: ._showExperimental) ?? false
self.experimental = try container.decode(UserPreferences.Experimental.self, forKey: ._experimental) ?? .init()
self.displayedName = try container.decodeIfPresent(DisplayedName.self, forKey: ._displayedName) ?? .username
self.profilePictureShape = try container.decodeIfPresent(ProfilePictureShape.self, forKey: ._profilePictureShape) ?? .circle
self.browserType = try container.decodeIfPresent(BrowserType.self, forKey: ._browserType) ?? .inApp
self.defaultVisibility = try container.decodeIfPresent(Visibility.self, forKey: ._defaultVisibility) ?? .pub
self.showExperimental = try container.decodeIfPresent(Bool.self, forKey: ._showExperimental) ?? false
self.experimental = try container.decodeIfPresent(UserPreferences.Experimental.self, forKey: ._experimental) ?? .init()
}
// Enums and other