Simplify code
This commit is contained in:
parent
9e027b878a
commit
64956c6643
2 changed files with 7 additions and 9 deletions
|
|
@ -21,6 +21,7 @@ public class Password {
|
|||
private var parser = Parser(plainText: "")
|
||||
private var additions = [AdditionField]()
|
||||
private var firstLineIsOTPField = false
|
||||
|
||||
private var otpToken: Token? {
|
||||
didSet {
|
||||
otpType = OtpType(token: otpToken)
|
||||
|
|
@ -82,11 +83,11 @@ public class Password {
|
|||
|
||||
if self.plainText != plainText {
|
||||
self.plainText = plainText
|
||||
changed = changed|PasswordChange.content.rawValue
|
||||
changed |= PasswordChange.content.rawValue
|
||||
}
|
||||
if self.url != url {
|
||||
self.url = url
|
||||
changed = changed|PasswordChange.path.rawValue
|
||||
changed |= PasswordChange.path.rawValue
|
||||
}
|
||||
|
||||
self.name = name
|
||||
|
|
@ -171,7 +172,7 @@ public class Password {
|
|||
return nil
|
||||
}
|
||||
var description = otpType.description
|
||||
if case let .timer(period)? = otpToken?.generator.factor {
|
||||
if case let .timer(period) = otpToken!.generator.factor {
|
||||
let timeSinceEpoch = Date().timeIntervalSince1970
|
||||
let validTime = Int(period - timeSinceEpoch.truncatingRemainder(dividingBy: period))
|
||||
description += " (expires in \(validTime)s)"
|
||||
|
|
|
|||
|
|
@ -12,13 +12,10 @@ import SwiftyUserDefaults
|
|||
extension PasswordEntity {
|
||||
|
||||
public var nameWithCategory: String {
|
||||
get {
|
||||
if let p = path, p.hasSuffix(".gpg") {
|
||||
return String(p.prefix(upTo: p.index(p.endIndex, offsetBy: -4)))
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
if let p = path, p.hasSuffix(".gpg") {
|
||||
return String(p.prefix(upTo: p.index(p.endIndex, offsetBy: -4)))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
public func getCategoryText() -> String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue