perf: fix weird lag when switching timelines

This commit is contained in:
William Casarin
2023-09-10 16:11:39 -07:00
parent 36acdf420e
commit 5b901656f3
2 changed files with 9 additions and 9 deletions

View File

@@ -30,8 +30,8 @@ struct FullKeypair: Equatable {
struct Keypair { struct Keypair {
let pubkey: Pubkey let pubkey: Pubkey
let privkey: Privkey? let privkey: Privkey?
let pubkey_bech32: String //let pubkey_bech32: String
let privkey_bech32: String? //let privkey_bech32: String?
static var empty: Keypair { static var empty: Keypair {
Keypair(pubkey: .empty, privkey: nil) Keypair(pubkey: .empty, privkey: nil)
@@ -52,8 +52,8 @@ struct Keypair {
init(pubkey: Pubkey, privkey: Privkey?) { init(pubkey: Pubkey, privkey: Privkey?) {
self.pubkey = pubkey self.pubkey = pubkey
self.privkey = privkey self.privkey = privkey
self.pubkey_bech32 = pubkey.npub //self.pubkey_bech32 = pubkey.npub
self.privkey_bech32 = privkey?.nsec //self.privkey_bech32 = privkey?.nsec
} }
} }

View File

@@ -20,7 +20,7 @@ struct KeySettingsView: View {
@Environment(\.dismiss) var dismiss @Environment(\.dismiss) var dismiss
init(keypair: Keypair) { init(keypair: Keypair) {
_privkey = State(initialValue: keypair.privkey_bech32 ?? "") _privkey = State(initialValue: keypair.privkey?.nsec ?? "")
self.keypair = keypair self.keypair = keypair
} }
@@ -40,7 +40,7 @@ struct KeySettingsView: View {
func CopyButton(is_pk: Bool) -> some View { func CopyButton(is_pk: Bool) -> some View {
return Button(action: { return Button(action: {
let copyKey = { let copyKey = {
UIPasteboard.general.string = is_pk ? self.keypair.pubkey_bech32 : self.privkey UIPasteboard.general.string = is_pk ? self.keypair.pubkey.npub : self.privkey
self.privkey_copied = !is_pk self.privkey_copied = !is_pk
self.pubkey_copied = is_pk self.pubkey_copied = is_pk
@@ -74,14 +74,14 @@ struct KeySettingsView: View {
Form { Form {
Section(NSLocalizedString("Public Account ID", comment: "Section title for the user's public account ID.")) { Section(NSLocalizedString("Public Account ID", comment: "Section title for the user's public account ID.")) {
HStack { HStack {
Text(keypair.pubkey_bech32) Text(keypair.pubkey.npub)
CopyButton(is_pk: true) CopyButton(is_pk: true)
} }
.clipShape(RoundedRectangle(cornerRadius: 5)) .clipShape(RoundedRectangle(cornerRadius: 5))
} }
if let sec = keypair.privkey_bech32 { if let sec = keypair.privkey?.nsec {
Section(NSLocalizedString("Secret Account Login Key", comment: "Section title for user's secret account login key.")) { Section(NSLocalizedString("Secret Account Login Key", comment: "Section title for user's secret account login key.")) {
HStack { HStack {
if show_privkey == false || !has_authenticated_locally { if show_privkey == false || !has_authenticated_locally {