@@ -197,11 +197,8 @@ class HomeModel: ObservableObject {
|
|||||||
var friends = damus_state.contacts.get_friend_list()
|
var friends = damus_state.contacts.get_friend_list()
|
||||||
friends.append(damus_state.pubkey)
|
friends.append(damus_state.pubkey)
|
||||||
|
|
||||||
var contacts_filter = NostrFilter.filter_kinds([0,3])
|
var contacts_filter = NostrFilter.filter_kinds([0])
|
||||||
var friendosphere = damus_state.contacts.get_friendosphere()
|
contacts_filter.authors = friends
|
||||||
friendosphere.append(damus_state.pubkey)
|
|
||||||
|
|
||||||
contacts_filter.authors = friendosphere
|
|
||||||
|
|
||||||
// TODO: separate likes?
|
// TODO: separate likes?
|
||||||
var home_filter = NostrFilter.filter_kinds([
|
var home_filter = NostrFilter.filter_kinds([
|
||||||
@@ -211,7 +208,7 @@ class HomeModel: ObservableObject {
|
|||||||
])
|
])
|
||||||
// include our pubkey as well even if we're not technically a friend
|
// include our pubkey as well even if we're not technically a friend
|
||||||
home_filter.authors = friends
|
home_filter.authors = friends
|
||||||
home_filter.limit = 1000
|
home_filter.limit = 500
|
||||||
|
|
||||||
var notifications_filter = NostrFilter.filter_kinds([
|
var notifications_filter = NostrFilter.filter_kinds([
|
||||||
NostrKind.text.rawValue,
|
NostrKind.text.rawValue,
|
||||||
@@ -219,7 +216,7 @@ class HomeModel: ObservableObject {
|
|||||||
NostrKind.boost.rawValue,
|
NostrKind.boost.rawValue,
|
||||||
])
|
])
|
||||||
notifications_filter.pubkeys = [damus_state.pubkey]
|
notifications_filter.pubkeys = [damus_state.pubkey]
|
||||||
notifications_filter.limit = 1000
|
notifications_filter.limit = 100
|
||||||
|
|
||||||
var home_filters = [home_filter]
|
var home_filters = [home_filter]
|
||||||
var notifications_filters = [notifications_filter]
|
var notifications_filters = [notifications_filter]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
struct Profile: Decodable {
|
struct Profile: Decodable {
|
||||||
let name: String?
|
let name: String?
|
||||||
|
let display_name: String?
|
||||||
let about: String?
|
let about: String?
|
||||||
let picture: String?
|
let picture: String?
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ struct ChatView: View {
|
|||||||
.padding(6)
|
.padding(6)
|
||||||
}
|
}
|
||||||
.padding([.leading], 2)
|
.padding([.leading], 2)
|
||||||
.background(Color.secondary.opacity(0.1))
|
.background(colorScheme == .light ? Color.secondary.opacity(0.1) : Color.secondary.opacity(0.25))
|
||||||
.cornerRadius(8.0)
|
.cornerRadius(8.0)
|
||||||
|
|
||||||
//.border(Color.red)
|
//.border(Color.red)
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ struct EventActionBar: View {
|
|||||||
EventActionButton(img: "bubble.left", col: nil) {
|
EventActionButton(img: "bubble.left", col: nil) {
|
||||||
notify(.reply, event)
|
notify(.reply, event)
|
||||||
}
|
}
|
||||||
.padding([.trailing], 20)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack(alignment: .bottom) {
|
HStack(alignment: .bottom) {
|
||||||
@@ -54,7 +53,6 @@ struct EventActionBar: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding([.trailing], 20)
|
|
||||||
|
|
||||||
HStack(alignment: .bottom) {
|
HStack(alignment: .bottom) {
|
||||||
Text("\(bar.boosts > 0 ? "\(bar.boosts)" : "")")
|
Text("\(bar.boosts > 0 ? "\(bar.boosts)" : "")")
|
||||||
@@ -69,7 +67,6 @@ struct EventActionBar: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding([.trailing], 20)
|
|
||||||
|
|
||||||
HStack(alignment: .bottom) {
|
HStack(alignment: .bottom) {
|
||||||
Text("\(bar.tips > 0 ? "\(bar.tips)" : "")")
|
Text("\(bar.tips > 0 ? "\(bar.tips)" : "")")
|
||||||
@@ -78,13 +75,12 @@ struct EventActionBar: View {
|
|||||||
|
|
||||||
EventActionButton(img: bar.tipped ? "bitcoinsign.circle.fill" : "bitcoinsign.circle", col: bar.tipped ? Color.orange : nil) {
|
EventActionButton(img: bar.tipped ? "bitcoinsign.circle.fill" : "bitcoinsign.circle", col: bar.tipped ? Color.orange : nil) {
|
||||||
if bar.tipped {
|
if bar.tipped {
|
||||||
notify(.delete, bar.our_tip)
|
//notify(.delete, bar.our_tip)
|
||||||
} else {
|
} else {
|
||||||
notify(.boost, event)
|
//notify(.boost, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.onReceive(handle_notify(.liked)) { n in
|
.onReceive(handle_notify(.liked)) { n in
|
||||||
let liked = n.object as! Counted
|
let liked = n.object as! Counted
|
||||||
@@ -104,6 +100,7 @@ func EventActionButton(img: String, col: Color?, action: @escaping () -> ()) ->
|
|||||||
Button(action: action) {
|
Button(action: action) {
|
||||||
Label("", systemImage: img)
|
Label("", systemImage: img)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
.foregroundColor(col == nil ? Color.gray : col!)
|
.foregroundColor(col == nil ? Color.gray : col!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,12 +78,11 @@ struct EventView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
||||||
VStack {
|
VStack(alignment: .leading) {
|
||||||
HStack {
|
HStack(alignment: .center) {
|
||||||
ProfileName(pubkey: event.pubkey, profile: profile)
|
ProfileName(pubkey: event.pubkey, profile: profile)
|
||||||
Text("\(format_relative_time(event.created_at))")
|
Text("\(format_relative_time(event.created_at))")
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
Spacer()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.is_reply {
|
if event.is_reply {
|
||||||
@@ -97,8 +96,6 @@ struct EventView: View {
|
|||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.textSelection(.enabled)
|
.textSelection(.enabled)
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
if has_action_bar {
|
if has_action_bar {
|
||||||
let bar = make_actionbar_model(ev: event, damus: damus)
|
let bar = make_actionbar_model(ev: event, damus: damus)
|
||||||
EventActionBar(event: event, keypair: damus.keypair, profiles: damus.profiles, bar: bar)
|
EventActionBar(event: event, keypair: damus.keypair, profiles: damus.profiles, bar: bar)
|
||||||
|
|||||||
@@ -7,23 +7,59 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ProfileName: View {
|
struct ProfileFullName: View {
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
let profile: Profile?
|
let profile: Profile?
|
||||||
|
|
||||||
@State var display_name: String?
|
@State var display_name: String?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Text(String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey)))
|
HStack {
|
||||||
//.foregroundColor(hex_to_rgb(pubkey))
|
if let real_name = profile?.display_name {
|
||||||
.bold()
|
Text(real_name)
|
||||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
.bold()
|
||||||
let update = notif.object as! ProfileUpdate
|
ProfileName(pubkey: pubkey, profile: profile, prefix: "@")
|
||||||
if update.pubkey != pubkey {
|
.font(.footnote)
|
||||||
return
|
.foregroundColor(.gray)
|
||||||
}
|
} else {
|
||||||
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey)
|
ProfileName(pubkey: pubkey, profile: profile)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ProfileName: View {
|
||||||
|
let pubkey: String
|
||||||
|
let profile: Profile?
|
||||||
|
let prefix: String
|
||||||
|
|
||||||
|
@State var display_name: String?
|
||||||
|
|
||||||
|
init(pubkey: String, profile: Profile?) {
|
||||||
|
self.pubkey = pubkey
|
||||||
|
self.profile = profile
|
||||||
|
self.prefix = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
init(pubkey: String, profile: Profile?, prefix: String) {
|
||||||
|
self.pubkey = pubkey
|
||||||
|
self.profile = profile
|
||||||
|
self.prefix = prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey)))
|
||||||
|
//.foregroundColor(hex_to_rgb(pubkey))
|
||||||
|
.fontWeight(prefix == "@" ? .none : .bold)
|
||||||
|
}
|
||||||
|
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||||
|
let update = notif.object as! ProfileUpdate
|
||||||
|
if update.pubkey != pubkey {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ struct ProfilePicView: View {
|
|||||||
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: "Will", about: "It's me", picture: picture)
|
let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture)
|
||||||
let ts_profile = TimestampedProfile(profile: profile, timestamp: 0)
|
let ts_profile = TimestampedProfile(profile: profile, timestamp: 0)
|
||||||
profiles.add(id: pubkey, profile: ts_profile)
|
profiles.add(id: pubkey, profile: ts_profile)
|
||||||
return profiles
|
return profiles
|
||||||
|
|||||||
@@ -56,26 +56,33 @@ struct ProfileView: View {
|
|||||||
var TopSection: some View {
|
var TopSection: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
let data = damus_state.profiles.lookup(id: profile.pubkey)
|
let data = damus_state.profiles.lookup(id: profile.pubkey)
|
||||||
HStack(alignment: .top) {
|
|
||||||
|
HStack(alignment: .center) {
|
||||||
ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE, highlight: .custom(Color.black, 2), image_cache: damus_state.image_cache, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE, highlight: .custom(Color.black, 2), image_cache: damus_state.image_cache, profiles: damus_state.profiles)
|
||||||
|
|
||||||
|
if let real_name = data?.display_name {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text(real_name)
|
||||||
|
.font(.title)
|
||||||
|
ProfileName(pubkey: profile.pubkey, profile: data, prefix: "@")
|
||||||
|
.font(.callout)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ProfileName(pubkey: profile.pubkey, profile: data)
|
||||||
|
}
|
||||||
|
//.border(Color.green)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
FollowButtonView(target: profile.get_follow_target(), follow_state: damus_state.contacts.follow_state(profile.pubkey))
|
FollowButtonView(target: profile.get_follow_target(), follow_state: damus_state.contacts.follow_state(profile.pubkey))
|
||||||
}
|
}
|
||||||
|
|
||||||
if let pubkey = profile.pubkey {
|
KeyView(pubkey: profile.pubkey)
|
||||||
ProfileName(pubkey: pubkey, profile: data)
|
.padding(.bottom, 10)
|
||||||
.font(.title)
|
|
||||||
//.border(Color.green)
|
|
||||||
Text("\(pubkey)")
|
|
||||||
.textSelection(.enabled)
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundColor(id_to_color(pubkey))
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(data?.about ?? "")
|
Text(data?.about ?? "")
|
||||||
|
|
||||||
if let contact = profile.contacts {
|
if let contact = profile.contacts {
|
||||||
Divider()
|
Divider()
|
||||||
|
|
||||||
@@ -118,10 +125,42 @@ struct ProfileView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
struct ProfileView_Previews: PreviewProvider {
|
struct ProfileView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ProfileView()
|
let ds = test_damus_state()
|
||||||
|
let profile_model = ProfileModel(pubkey: ds.pubkey, damus: ds)
|
||||||
|
ProfileView(damus_state: ds, profile: profile_model)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
func test_damus_state() -> DamusState {
|
||||||
|
let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681"
|
||||||
|
let damus = DamusState(pool: RelayPool(), keypair: Keypair(pubkey: pubkey, privkey: "privkey"), likes: EventCounter(our_pubkey: pubkey), boosts: EventCounter(our_pubkey: pubkey), contacts: Contacts(), tips: TipCounter(our_pubkey: pubkey), image_cache: ImageCache(), profiles: Profiles())
|
||||||
|
|
||||||
|
let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png")
|
||||||
|
let tsprof = TimestampedProfile(profile: prof, timestamp: 0)
|
||||||
|
damus.profiles.add(id: pubkey, profile: tsprof)
|
||||||
|
return damus
|
||||||
|
}
|
||||||
|
|
||||||
|
struct KeyView: View {
|
||||||
|
let pubkey: String
|
||||||
|
|
||||||
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
let col = id_to_color(pubkey)
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
Text("\(String(pubkey.prefix(32)))")
|
||||||
|
.foregroundColor(colorScheme == .light ? .black : col)
|
||||||
|
.font(.footnote.monospaced())
|
||||||
|
Text("\(String(pubkey.suffix(32)))")
|
||||||
|
.font(.footnote.monospaced())
|
||||||
|
.foregroundColor(colorScheme == .light ? .black : col)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user