diff --git a/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift b/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift index 543e6a99e..7d22dc39a 100644 --- a/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift +++ b/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift @@ -2,7 +2,7 @@ import Foundation struct CipherMock { static let ciphers:[Cipher] = [ - Cipher(id: "0", name: "1933", userId: "123123", login: Login(username: "thisisatest@testing.com", totp: "otpauth://account?period=10&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), + Cipher(id: "0", name: "MySite", userId: "123123", login: Login(username: "test@testing.com", totp: "otpauth://account?period=10&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), Cipher(id: "1", name: "GitHub", userId: "123123", login: Login(username: "thisisatest@testing.com", totp: "LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), Cipher(id: "2", name: "No user", userId: "123123", login: Login(username: nil, totp: "otpauth://account?period=10&digits=8&algorithm=sha256&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), Cipher(id: "3", name: "Site 2", userId: "123123", login: Login(username: "longtestemail000000@fastmailasdfasdf.com", totp: "otpauth://account?period=10&digits=7&algorithm=sha512&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), diff --git a/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift b/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift index bfed0a30b..41663d9dd 100644 --- a/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift +++ b/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift @@ -34,30 +34,34 @@ class CipherDetailsViewModel: ObservableObject{ self.counter = self.period - mod self.progress = Double(self.counter) / Double(self.period) } + if mod == 0 || self.totpFormatted == "" { do { - var totpF = try TotpService.shared.GetCodeAsync(key: self.key) ?? "" - if totpF.count > 4 { - let halfIndex = totpF.index(totpF.startIndex, offsetBy: totpF.count / 2) - totpF = "\(totpF[totpF.startIndex.. 4 { + let halfIndex = totpF.index(totpF.startIndex, offsetBy: totpF.count / 2) + totpF = "\(totpF[totpF.startIndex..