insert sort, profile updates revamp

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-05-09 10:33:03 -07:00
parent 0ab1494b1e
commit 6ac4214be7
26 changed files with 250 additions and 95 deletions

View File

@@ -37,11 +37,11 @@ struct ProfilePicView: View {
let size: CGFloat
let highlight: Highlight
let image_cache: ImageCache
let profiles: Profiles
@State var picture: String? = nil
@State var img: Image? = nil
@EnvironmentObject var profiles: Profiles
var PlaceholderColor: Color {
return id_to_color(pubkey)
}
@@ -76,7 +76,7 @@ struct ProfilePicView: View {
var MainContent: some View {
Group {
let picture = profiles.lookup(id: pubkey)?.picture
let picture = picture ?? profiles.lookup(id: pubkey)?.picture
if let pic_url = picture.flatMap { URL(string: $0) } {
ProfilePic(pic_url)
} else {
@@ -87,6 +87,16 @@ struct ProfilePicView: View {
var body: some View {
MainContent
.onReceive(handle_notify(.profile_updated)) { notif in
let updated = notif.object as! ProfileUpdate
if updated.pubkey != pubkey {
return
}
if updated.profile.picture != picture {
picture = updated.profile.picture
}
}
}
}