Fake PR to identify cause of CI test failure #27

Closed
tyiu wants to merge 1 commits from tyiu/find-test-failure into tyiu/find-test-failure-2
5 changed files with 31 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ import Foundation
class Profile: Codable { class Profile: Codable {
var value: [String: AnyCodable] var value: [String: AnyCodable]
init (name: String?, display_name: String?, about: String?, picture: String?, banner: String?, website: String?, lud06: String?, lud16: String?, nip05: String?) { init (name: String?, display_name: String?, about: String?, picture: String?, banner: String?, website: String?, lud06: String?, lud16: String?, nip05: String?, damus_donation: Int?) {
self.value = [:] self.value = [:]
self.name = name self.name = name
self.display_name = display_name self.display_name = display_name
@@ -21,12 +21,17 @@ class Profile: Codable {
self.lud06 = lud06 self.lud06 = lud06
self.lud16 = lud16 self.lud16 = lud16
self.nip05 = nip05 self.nip05 = nip05
self.damus_donation = damus_donation
} }
private func str(_ str: String) -> String? { private func str(_ str: String) -> String? {
return get_val(str) return get_val(str)
} }
private func int(_ key: String) -> Int? {
return get_val(key)
}
private func get_val<T>(_ v: String) -> T? { private func get_val<T>(_ v: String) -> T? {
guard let val = self.value[v] else{ guard let val = self.value[v] else{
return nil return nil
@@ -52,6 +57,10 @@ class Profile: Codable {
set_val(key, val) set_val(key, val)
} }
private func set_int(_ key: String, _ val: Int?) {
set_val(key, val)
}
var reactions: Bool? { var reactions: Bool? {
get { return get_val("reactions"); } get { return get_val("reactions"); }
set(s) { set_val("reactions", s) } set(s) { set_val("reactions", s) }
@@ -77,6 +86,11 @@ class Profile: Codable {
set(s) { set_str("about", s) } set(s) { set_str("about", s) }
} }
var damus_donation: Int? {
get { return int("damus_donation"); }
set(s) { set_int("damus_donation", s) }
}
var picture: String? { var picture: String? {
get { return str("picture"); } get { return str("picture"); }
set(s) { set_str("picture", s) } set(s) { set_str("picture", s) }
@@ -180,7 +194,7 @@ class Profile: Codable {
} }
func make_test_profile() -> Profile { func make_test_profile() -> Profile {
return Profile(name: "jb55", display_name: "Will", about: "Its a me", picture: "https://cdn.jb55.com/img/red-me.jpg", banner: "https://pbs.twimg.com/profile_banners/9918032/1531711830/600x200", website: "jb55.com", lud06: "jb55@jb55.com", lud16: nil, nip05: "jb55@jb55.com") return Profile(name: "jb55", display_name: "Will", about: "Its a me", picture: "https://cdn.jb55.com/img/red-me.jpg", banner: "https://pbs.twimg.com/profile_banners/9918032/1531711830/600x200", website: "jb55.com", lud06: "jb55@jb55.com", lud16: nil, nip05: "jb55@jb55.com", damus_donation: 1)
} }
func make_ln_url(_ str: String?) -> URL? { func make_ln_url(_ str: String?) -> URL? {

View File

@@ -177,7 +177,7 @@ func get_profile_url(picture: String?, pubkey: String, profiles: Profiles) -> UR
func make_preview_profiles(_ pubkey: String) -> Profiles { func make_preview_profiles(_ pubkey: String) -> Profiles {
let profiles = Profiles() let profiles = Profiles()
let picture = "http://cdn.jb55.com/img/red-me.jpg" let picture = "http://cdn.jb55.com/img/red-me.jpg"
let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, banner: "", website: "https://jb55.com", lud06: nil, lud16: nil, nip05: "jb55.com") let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, banner: "", website: "https://jb55.com", lud06: nil, lud16: nil, nip05: "jb55.com", damus_donation: nil)
let ts_profile = TimestampedProfile(profile: profile, timestamp: 0, event: test_event) let ts_profile = TimestampedProfile(profile: profile, timestamp: 0, event: test_event)
profiles.add(id: pubkey, profile: ts_profile) profiles.add(id: pubkey, profile: ts_profile)
return profiles return profiles

View File

@@ -497,7 +497,7 @@ func test_damus_state() -> DamusState {
let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681" let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681"
let damus = DamusState.empty let damus = DamusState.empty
let prof = Profile(name: "damus", display_name: "damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", banner: "", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io") let prof = Profile(name: "damus", display_name: "damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", banner: "", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io", damus_donation: nil)
let tsprof = TimestampedProfile(profile: prof, timestamp: 0, event: test_event) let tsprof = TimestampedProfile(profile: prof, timestamp: 0, event: test_event)
damus.profiles.add(id: pubkey, profile: tsprof) damus.profiles.add(id: pubkey, profile: tsprof)
return damus return damus

View File

@@ -224,5 +224,5 @@ struct SaveKeysView_Previews: PreviewProvider {
} }
func create_account_to_metadata(_ model: CreateAccountModel) -> Profile { func create_account_to_metadata(_ model: CreateAccountModel) -> Profile {
return Profile(name: model.nick_name, display_name: model.real_name, about: model.about, picture: model.profile_image, banner: nil, website: nil, lud06: nil, lud16: nil, nip05: nil) return Profile(name: model.nick_name, display_name: model.real_name, about: model.about, picture: model.profile_image, banner: nil, website: nil, lud06: nil, lud16: nil, nip05: nil, damus_donation: nil)
} }

View File

@@ -154,6 +154,18 @@ struct WalletView: View {
ConnectWalletView(model: model) ConnectWalletView(model: model)
case .existing(let nwc): case .existing(let nwc):
MainWalletView(nwc: nwc) MainWalletView(nwc: nwc)
.onDisappear {
guard let keypair = damus_state.keypair.to_full(),
let profile = damus_state.profiles.lookup(id: damus_state.pubkey),
profile.damus_donation != settings.donation_percent
else {
return
}
profile.damus_donation = settings.donation_percent
let meta = make_metadata_event(keypair: keypair, metadata: profile)
damus_state.postbox.send(meta)
}
} }
} }
} }