Skip to content

Commit

Permalink
Merge pull request #1325 from Infomaniak/fix-multiple-selection-actio…
Browse files Browse the repository at this point in the history
…n-not-same-between-ios-and-android

fix: Multiple selection action not same between iOS and Android, plus fix color
  • Loading branch information
PhilippeWeidmann authored Oct 18, 2024
2 parents 2e7e46a + 3569292 commit b713d6b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions kDriveCore/Data/Cache/DriveFileManager/DriveFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion kDriveCore/Data/Models/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -829,6 +829,7 @@ public final class File: Object, Codable {
uid = File.uid(driveId: driveId, fileId: id)
}
rawType = "dir"
rawVisibility = visibility?.rawValue ?? ""
children = MutableSet<File>()
}
}
Expand Down
5 changes: 5 additions & 0 deletions kDriveCore/Data/Models/Rights.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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() {
Expand All @@ -119,5 +123,6 @@ extension Rights: ContentEquatable {
&& canUpload == source.canUpload
&& canMoveInto == source.canMoveInto
&& canBecomeDropbox == source.canBecomeDropbox
&& canColor == source.canColor
}
}

0 comments on commit b713d6b

Please sign in to comment.