Enable editing on Pleroma 2.5+

This commit is contained in:
Shadowfacts 2023-05-14 13:55:28 -04:00
parent b00170c3f9
commit c94e60d49b
2 changed files with 29 additions and 5 deletions

View File

@ -88,7 +88,7 @@ public class InstanceFeatures: ObservableObject {
}
public var needsWideColorGamutHack: Bool {
if case .mastodon(_, .some(let version)) = instanceType {
if case .mastodon(_, let version) = instanceType {
return version < Version(4, 0, 0)
} else {
return true
@ -116,8 +116,16 @@ public class InstanceFeatures: ObservableObject {
}
public var editStatuses: Bool {
// todo: does this require a particular akkoma version?
hasMastodonVersion(3, 5, 0) || instanceType.isPleroma(.akkoma(nil))
switch instanceType {
case .mastodon(_, let v) where v >= Version(3, 5, 0):
return true
case .pleroma(.vanilla(let v)) where v >= Version(2, 5, 0):
return true
case .pleroma(.akkoma(nil)):
return true
default:
return false
}
}
public var needsEditAttachmentsInSeparateRequest: Bool {
@ -188,7 +196,7 @@ public class InstanceFeatures: ObservableObject {
}
public func hasMastodonVersion(_ major: Int, _ minor: Int, _ patch: Int) -> Bool {
if case .mastodon(_, .some(let version)) = instanceType {
if case .mastodon(_, let version) = instanceType {
return version >= Version(major, minor, patch)
} else {
return false
@ -197,7 +205,7 @@ public class InstanceFeatures: ObservableObject {
func hasPleromaVersion(_ major: Int, _ minor: Int, _ patch: Int) -> Bool {
switch instanceType {
case .pleroma(.vanilla(.some(let version))), .pleroma(.akkoma(.some(let version))):
case .pleroma(.vanilla(let version)), .pleroma(.akkoma(let version)):
return version >= Version(major, minor, patch)
default:
return false

View File

@ -62,3 +62,19 @@ import Foundation
}
}
}
func <(lhs: Version?, rhs: Version) -> Bool {
guard let lhs else {
// nil is less than or equal to everything
return true
}
return lhs < rhs
}
func >=(lhs: Version?, rhs: Version) -> Bool {
guard let lhs else {
// nil is less than or equal to everything
return false
}
return lhs >= rhs
}