Skip to content

Commit

Permalink
politeia: load proposal description in details page
Browse files Browse the repository at this point in the history
Proposal descriptions are now loaded from the server if the description
is outdated or not yet saved by dcrlibwallet.
  • Loading branch information
beansgum committed May 11, 2021
1 parent 6486d46 commit a59bf59
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 35 deletions.
5 changes: 4 additions & 1 deletion Decred Wallet/DcrlibwalletTypes/Politeia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Politeia: Codable {
var version: String
var publishedat: Date
var indexfile: String
var fileversion: String
var votestatus: PoliteiaVoteStatus
var voteapproved: Bool
var yesvotes: Int32
Expand All @@ -33,7 +34,7 @@ struct Politeia: Codable {
var yesPercent: Float

private enum CodingKeys : String, CodingKey {
case ID, token, category, name, state, status, timestamp, userid, username, numcomments, version, publishedat, indexfile, votestatus, voteapproved, yesvotes, novotes, eligibletickets, quorumpercentage, passpercentage
case ID, token, category, name, state, status, timestamp, userid, username, numcomments, version, publishedat, indexfile, fileversion, votestatus, voteapproved, yesvotes, novotes, eligibletickets, quorumpercentage, passpercentage
}

init(from decoder: Decoder) throws {
Expand All @@ -50,6 +51,7 @@ struct Politeia: Codable {
self.version = try! values.decode(String.self, forKey: .version)
self.publishedat = try! values.decode(Date.self, forKey: .publishedat)
self.indexfile = try! values.decode(String.self, forKey: .indexfile)
self.fileversion = try! values.decode(String.self, forKey: .fileversion)
self.status = try! values.decode(Int32.self, forKey: .status)
self.voteapproved = try! values.decode(Bool.self, forKey: .voteapproved)
self.yesvotes = try! values.decode(Int32.self, forKey: .yesvotes)
Expand Down Expand Up @@ -84,6 +86,7 @@ struct Politeia: Codable {
self.version = proposal.version
self.publishedat = Date(milliseconds: Int(proposal.publishedAt))
self.indexfile = proposal.indexFile
self.fileversion = proposal.indexFileVersion
self.status = proposal.status
self.voteapproved = proposal.voteApproved
self.yesvotes = proposal.yesVotes
Expand Down
Loading

0 comments on commit a59bf59

Please sign in to comment.