Merge pull request #357 from James-Sangalli/fix-ticket-token-name-not-localized-when-user-change-locale

Fix: ticket token name is not localized when user changes locale
pull/362/head
James Sangalli 7 years ago committed by GitHub
commit 9b20fd34c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      Trust/Tokens/Types/TokensDataStore.swift

@ -86,6 +86,8 @@ class TokensDataStore {
self.addEthToken()
self.scheduledTimerForPricesUpdate()
self.scheduledTimerForEthBalanceUpdate()
updateTicketTokenToLocalizedName()
}
private func addEthToken() {
//Check if we have previos values.
@ -335,6 +337,23 @@ class TokensDataStore {
self?.refreshETHBalance()
}, selector: #selector(Operation.main), userInfo: nil, repeats: true)
}
private func updateTicketTokenToLocalizedName() {
if let token = config.createDefaultTicketToken() {
let contract = token.contract.eip55String
let localizedName = token.name
if let storedTicketToken = enabledObject.first(where: { $0.contract == contract}) {
updateTicketTokenName(token: storedTicketToken, to: localizedName)
}
}
}
private func updateTicketTokenName(token: TokenObject, to name: String) {
try! realm.write {
token.name = name
}
}
deinit {
//We should make sure that timer is invalidate.
pricesTimer.invalidate()

Loading…
Cancel
Save