Skip to content

Commit

Permalink
Merge pull request #1446 from Infomaniak/fix/use-api-to-set-colorable…
Browse files Browse the repository at this point in the history
…-right

Add colorable right to File
  • Loading branch information
TommyDL-Infomaniak authored Oct 2, 2024
2 parents ec08a1b + 7380cf2 commit 163bf04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,15 @@ class FileMigration : RealmMigration {

oldVersionTemp++
}

// Migrated to version 8
if (oldVersionTemp == 7L) {
schema.get("Rights")?.apply {
addField("colorable", Boolean::class.java, FieldAttribute.REQUIRED)
}

oldVersionTemp++
}
}

override fun equals(other: Any?): Boolean {
Expand Down Expand Up @@ -376,7 +385,7 @@ class FileMigration : RealmMigration {
}

companion object {
const val dbVersion = 7L // Must be bumped when the schema changes
const val dbVersion = 8L // Must be bumped when the schema changes
const val LOGOUT_CURRENT_USER_TAG = "logout_current_user_tag"
}
}
7 changes: 1 addition & 6 deletions app/src/main/java/com/infomaniak/drive/data/models/File.kt
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,7 @@ open class File(
}
}

fun isAllowedToBeColored(): Boolean {
return !isDisabled()
&& isFolder()
&& getVisibilityType() != VisibilityType.IS_SHARED_SPACE
&& getVisibilityType() != VisibilityType.IS_TEAM_SPACE
}
fun isAllowedToBeColored() = rights?.colorable ?: false

fun hasCreationRight() = isFolder() && rights?.canCreateFile == true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ open class Rights(
var canUseTeam: Boolean = false,
@SerializedName("can_write")
var canWrite: Boolean = false,
var colorable: Boolean = false,
var right: String = "",
) : RealmObject(), Parcelable {

Expand Down

0 comments on commit 163bf04

Please sign in to comment.