diff --git a/kDriveCore/Data/Cache/DriveInfosManager/DriveInfosManager.swift b/kDriveCore/Data/Cache/DriveInfosManager/DriveInfosManager.swift index aeee624b1..76742e9f7 100644 --- a/kDriveCore/Data/Cache/DriveInfosManager/DriveInfosManager.swift +++ b/kDriveCore/Data/Cache/DriveInfosManager/DriveInfosManager.swift @@ -51,7 +51,7 @@ public extension Results where Element: KeypathSortable { public final class DriveInfosManager: DriveInfosManagerQueryable { private static let dbName = "DrivesInfos.realm" - private static let currentDbVersion: UInt64 = 11 + private static let currentDbVersion: UInt64 = 12 let currentFpStorageVersion = 1 diff --git a/kDriveCore/Data/Models/Drive/Drive+Quota.swift b/kDriveCore/Data/Models/Drive/Drive+Quota.swift new file mode 100644 index 000000000..c8663fb83 --- /dev/null +++ b/kDriveCore/Data/Models/Drive/Drive+Quota.swift @@ -0,0 +1,43 @@ +/* + Infomaniak kDrive - iOS App + Copyright (C) 2025 Infomaniak Network SA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +import Foundation +import InfomaniakCore +import RealmSwift + +public final class DriveQuota: EmbeddedObject, Codable { + @Persisted public var dropbox: Int? + @Persisted public var sharedLink: Int? + + enum CodingKeys: String, CodingKey { + case dropbox + case sharedLink = "shared_link" + } +} + +extension Drive { + var dropboxQuotaExceeded: Bool { + // TODO: Use real quota data + true + } + + var sharedLinkQuotaExceeded: Bool { + // TODO: Use real quota data + true + } +} diff --git a/kDriveCore/Data/Models/Drive/Drive.swift b/kDriveCore/Data/Models/Drive/Drive.swift index 468788fa9..751f371f3 100644 --- a/kDriveCore/Data/Models/Drive/Drive.swift +++ b/kDriveCore/Data/Models/Drive/Drive.swift @@ -87,6 +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? /// Is manager admin. @Persisted public var accountAdmin = false /// Was product purchased with in-app purchase. @@ -170,6 +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) } override public init() { @@ -214,6 +216,7 @@ public final class Drive: Object, Codable { case _account = "account" case accountAdmin case isInAppSubscription + case quota } public static func == (lhs: Drive, rhs: Drive) -> Bool {