contacts: unify following logic

We are about to add hashtag following, so let's prepare handle_follow
for this. Generalize pubkey following to ReferenceId follows in the
handle_{follow,unfollow} functions.

We also split out the notification part into its own function.
This commit is contained in:
William Casarin
2023-07-13 09:30:26 -07:00
parent 0fae54a98d
commit bebaffd247
2 changed files with 51 additions and 35 deletions

View File

@@ -32,16 +32,16 @@ struct FollowButtonView: View {
}
}
.onReceive(handle_notify(.followed)) { notif in
let pk = notif.object as! String
if pk != target.pubkey {
let pk = notif.object as! ReferencedId
if pk.key == "p", pk.ref_id != target.pubkey {
return
}
self.follow_state = .follows
}
.onReceive(handle_notify(.unfollowed)) { notif in
let pk = notif.object as! String
if pk != target.pubkey {
let pk = notif.object as! ReferencedId
if pk.key == "p", pk.ref_id != target.pubkey {
return
}