Skip to content

Commit

Permalink
feat(Drive): Quota is now non nullable as discussed with backend
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Jan 30, 2025
1 parent c3f935a commit dcebce6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
18 changes: 2 additions & 16 deletions kDriveCore/Data/Models/Drive/Drive+Quota.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import InfomaniakCore
import RealmSwift

public final class DriveQuota: EmbeddedObject, Codable {
@Persisted public var dropbox: Int?
@Persisted public var sharedLink: Int?
@Persisted public var dropbox: Int
@Persisted public var sharedLink: Int

enum CodingKeys: String, CodingKey {
case dropbox
Expand All @@ -33,20 +33,6 @@ public final class DriveQuota: EmbeddedObject, Codable {
// Required by Realm
super.init()
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

let dropboxString = try container.decode(String.self, forKey: .dropbox)
if let dropbox = Int(dropboxString) {
self.dropbox = dropbox
}

let sharedLinkString = try container.decode(String.self, forKey: .sharedLink)
if let sharedLink = Int(sharedLinkString) {
self.sharedLink = sharedLink
}
}
}

extension Drive {
Expand Down
4 changes: 2 additions & 2 deletions kDriveCore/Data/Models/Drive/Drive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public final class Drive: Object, Codable {
@Persisted public var maintenanceReason: MaintenanceReason?
@Persisted public var updatedAt: Date
@Persisted public var _account: DriveAccount?
@Persisted public var quota: DriveQuota?
@Persisted public var quota: DriveQuota
/// Is manager admin.
@Persisted public var accountAdmin = false
/// Was product purchased with in-app purchase.
Expand Down Expand Up @@ -171,7 +171,7 @@ public final class Drive: Object, Codable {
_account = try values.decode(DriveAccount.self, forKey: ._account)
accountAdmin = try values.decode(Bool.self, forKey: .accountAdmin)
isInAppSubscription = try values.decode(Bool.self, forKey: .isInAppSubscription)
quota = try? values.decodeIfPresent(DriveQuota.self, forKey: .isInAppSubscription)
quota = try values.decode(DriveQuota.self, forKey: .isInAppSubscription)
}

override public init() {
Expand Down

0 comments on commit dcebce6

Please sign in to comment.