File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,23 @@ public struct RantInFeed: Decodable, Identifiable {
3737 /// * `0` = Unvoted
3838 /// * `-1` = Downvote
3939 /// * `-2` = Voting disabled (the rant belongs to the user whose token was used to fetch the rant)
40- public var voteState : Int
40+ public var voteStateRaw : Int
41+
42+ public enum VoteState : Int {
43+ case upvoted = 1
44+ case unvoted = 0
45+ case downvoted = - 1
46+ case unvotable = - 2
47+ }
48+
49+ public var voteState : VoteState {
50+ get {
51+ return VoteState ( rawValue: voteStateRaw) ?? . unvotable
52+ }
53+ set {
54+ voteStateRaw = newValue. rawValue
55+ }
56+ }
4157
4258 /// Whether or not the rant was edited in the past.
4359 public let isEdited : Bool
@@ -111,7 +127,7 @@ extension RantInFeed {
111127
112128 commentCount = try values. decode ( Int . self, forKey: . commentCount)
113129 tags = try values. decode ( [ String ] . self, forKey: . tags)
114- voteState = try values. decode ( Int . self, forKey: . voteState)
130+ voteStateRaw = try values. decode ( Int . self, forKey: . voteState)
115131 isEdited = try values. decode ( Bool . self, forKey: . isEdited)
116132 link = try ? values. decode ( String . self, forKey: . link)
117133 collabType = try ? values. decode ( Int . self, forKey: . collabType)
You can’t perform that action at this time.
0 commit comments