Skip to content

Commit

Permalink
Add optionSet for reblog again (mastodon#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Nov 8, 2022
1 parent 3751cd1 commit 21800a4
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MastodonLocalization
import CoreDataStack

public enum RelationshipAction: Int, CaseIterable {
case showReblogs
case isMyself
case followingBy
case blockingBy
Expand All @@ -27,8 +28,7 @@ public enum RelationshipAction: Int, CaseIterable {
case edit
case editing
case updating
case showReblogs


public var option: RelationshipActionOptionSet {
return RelationshipActionOptionSet(rawValue: 1 << rawValue)
}
Expand Down Expand Up @@ -58,6 +58,7 @@ public struct RelationshipActionOptionSet: OptionSet {
public static let edit = RelationshipAction.edit.option
public static let editing = RelationshipAction.editing.option
public static let updating = RelationshipAction.updating.option
public static let showReblogs = RelationshipAction.showReblogs.option
public static let editOptions: RelationshipActionOptionSet = [.edit, .editing, .updating]

public func highPriorityAction(except: RelationshipActionOptionSet) -> RelationshipAction? {
Expand Down Expand Up @@ -185,7 +186,7 @@ extension RelationshipViewModel {
self.isBlockingBy = optionSet.contains(.blockingBy)
self.isBlocking = optionSet.contains(.blocking)
self.isSuspended = optionSet.contains(.suspended)
self.showReblogs = me.showingReblogsBy.contains(user)
self.showReblogs = optionSet.contains(.showReblogs)

self.optionSet = optionSet
}
Expand Down Expand Up @@ -217,6 +218,7 @@ extension RelationshipViewModel {
let isMuting = user.mutingBy.contains(me)
let isBlockingBy = me.blockingBy.contains(user)
let isBlocking = user.blockingBy.contains(me)
let isShowingReblogs = me.showingReblogsBy.contains(user)

var optionSet: RelationshipActionOptionSet = [.follow]

Expand Down Expand Up @@ -256,6 +258,10 @@ extension RelationshipViewModel {
optionSet.insert(.suspended)
}

if isShowingReblogs {
optionSet.insert(.showReblogs)
}

return optionSet
}
}

0 comments on commit 21800a4

Please sign in to comment.