diff --git a/kDrive/UI/Controller/Files/FileActionsFloatingPanelViewController+Actions.swift b/kDrive/UI/Controller/Files/FileActionsFloatingPanelViewController+Actions.swift index bbcf13c7c..18c9780c0 100644 --- a/kDrive/UI/Controller/Files/FileActionsFloatingPanelViewController+Actions.swift +++ b/kDrive/UI/Controller/Files/FileActionsFloatingPanelViewController+Actions.swift @@ -73,7 +73,7 @@ extension FileActionsFloatingPanelViewController { case .manageDropbox: return file.isDropbox case .folderColor: - return file.canBeColored + return file.capabilities.canColor case .seeFolder: return !normalFolderHierarchy && (file.parent != nil || file.parentId != 0) case .offline: diff --git a/kDrive/UI/Controller/Files/MultipleSelectionFloatingPanelViewController.swift b/kDrive/UI/Controller/Files/MultipleSelectionFloatingPanelViewController.swift index a22f6035a..e13a0771a 100644 --- a/kDrive/UI/Controller/Files/MultipleSelectionFloatingPanelViewController.swift +++ b/kDrive/UI/Controller/Files/MultipleSelectionFloatingPanelViewController.swift @@ -45,7 +45,7 @@ final class MultipleSelectionFloatingPanelViewController: UICollectionViewContro weak var presentingParent: UIViewController? var sharedWithMe: Bool { - return currentDirectory.visibility == .isInSharedSpace + return currentDirectory.visibility == .isInSharedSpace || currentDirectory.visibility == .isSharedSpace } var actions = FloatingPanelAction.listActions diff --git a/kDriveCore/Data/Cache/DriveFileManager/DriveFileManager.swift b/kDriveCore/Data/Cache/DriveFileManager/DriveFileManager.swift index c7a25ee92..2f02b2cb1 100644 --- a/kDriveCore/Data/Cache/DriveFileManager/DriveFileManager.swift +++ b/kDriveCore/Data/Cache/DriveFileManager/DriveFileManager.swift @@ -42,10 +42,6 @@ public final class DriveFileManager { return File(id: -2, name: "Trash") } - public static var sharedWithMeRootFile: File { - return File(id: -3, name: "Shared with me") - } - public static var mySharedRootFile: File { return File(id: -4, name: "My shares") } @@ -72,6 +68,11 @@ public final class DriveFileManager { return offlineRoot } + public static var sharedWithMeRootFile: File { + // We can't migrate fake roots. Previous sharedWithMeRootFile.id was -3 + return File(id: -10, name: "Shared with me", visibility: .isSharedSpace) + } + public let realmConfiguration: Realm.Configuration // TODO: Fetch a drive with a computed property instead of tracking a Realm object @@ -186,6 +187,11 @@ public final class DriveFileManager { } } } + if oldSchemaVersion < 12 { + migration.enumerateObjects(ofType: Rights.className()) { _, newObject in + newObject?["canColor"] = false + } + } }, objectTypes: DriveFileManager.constants.driveObjectTypes ) diff --git a/kDriveCore/Data/Cache/DriveFileManager/DriveFileManagerConstants.swift b/kDriveCore/Data/Cache/DriveFileManager/DriveFileManagerConstants.swift index 9ce515899..b65c3f6d2 100644 --- a/kDriveCore/Data/Cache/DriveFileManager/DriveFileManagerConstants.swift +++ b/kDriveCore/Data/Cache/DriveFileManager/DriveFileManagerConstants.swift @@ -28,7 +28,7 @@ public enum RealmSchemaVersion { static let upload: UInt64 = 21 /// Current version of the Drive Realm - static let drive: UInt64 = 11 + static let drive: UInt64 = 12 } public class DriveFileManagerConstants { diff --git a/kDriveCore/Data/Models/File.swift b/kDriveCore/Data/Models/File.swift index 88bb3b3d4..33e0497bc 100644 --- a/kDriveCore/Data/Models/File.swift +++ b/kDriveCore/Data/Models/File.swift @@ -820,7 +820,7 @@ public final class File: Object, Codable { // primary key is set as default value } - convenience init(id: Int, name: String, driveId: Int? = nil) { + convenience init(id: Int, name: String, driveId: Int? = nil, visibility: FileVisibility? = nil) { self.init() self.id = id self.name = name @@ -829,6 +829,7 @@ public final class File: Object, Codable { uid = File.uid(driveId: driveId, fileId: id) } rawType = "dir" + rawVisibility = visibility?.rawValue ?? "" children = MutableSet() } } diff --git a/kDriveCore/Data/Models/Rights.swift b/kDriveCore/Data/Models/Rights.swift index 6d599a289..0f5271b76 100644 --- a/kDriveCore/Data/Models/Rights.swift +++ b/kDriveCore/Data/Models/Rights.swift @@ -43,6 +43,8 @@ public class Rights: EmbeddedObject, Codable { @Persisted public var canUseFavorite: Bool /// Right to use and give team access @Persisted public var canUseTeam: Bool + /// Right to color a folder + @Persisted public var canColor: Bool // Directory capabilities /// Right to add new child directory @@ -73,6 +75,7 @@ public class Rights: EmbeddedObject, Codable { case canUpload case canMoveInto case canBecomeDropbox + case canColor = "colorable" } public required init(from decoder: Decoder) throws { @@ -93,6 +96,7 @@ public class Rights: EmbeddedObject, Codable { canUpload = try container.decodeIfPresent(Bool.self, forKey: .canUpload) ?? false canMoveInto = try container.decodeIfPresent(Bool.self, forKey: .canMoveInto) ?? false canBecomeDropbox = try container.decodeIfPresent(Bool.self, forKey: .canBecomeDropbox) ?? false + canColor = try container.decodeIfPresent(Bool.self, forKey: .canColor) ?? false } override public init() { @@ -119,5 +123,6 @@ extension Rights: ContentEquatable { && canUpload == source.canUpload && canMoveInto == source.canMoveInto && canBecomeDropbox == source.canBecomeDropbox + && canColor == source.canColor } }