commit 0e8363289611214df4a41c0612cfc6033818b865
parent f0df4aa218cc1997e5db671149b7cbcf913c7fa8
Author: William Casarin <jb55@jb55.com>
Date: Mon, 13 Feb 2023 10:04:31 -0800
Revert "Add the ability to unlike posts"
This reverts commit 237c939639de2b2c13d7290d8f1d01489c52a331.
Diffstat:
5 files changed, 7 insertions(+), 59 deletions(-)
diff --git a/damus/ContentView.swift b/damus/ContentView.swift
@@ -387,12 +387,6 @@ struct ContentView: View {
}
.onReceive(handle_notify(.like)) { like in
}
- .onReceive(handle_notify(.delete)) { delete in
- guard let ev = delete.object as? NostrEvent else {
- return
- }
- self.home.handle_unlike_event(ev)
- }
.onReceive(handle_notify(.deleted_account)) { notif in
self.is_deleted_account = true
}
diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift
@@ -167,15 +167,6 @@ class HomeModel: ObservableObject {
}
}
-
- func handle_delete_event(_ ev: NostrEvent) {
- guard ev.is_valid else {
- return
- }
-
- self.deleted_events.insert(ev.id)
- }
-
func handle_channel_create(_ ev: NostrEvent) {
guard ev.is_valid else {
@@ -194,18 +185,13 @@ class HomeModel: ObservableObject {
self.notifications = notifications.filter { !damus_state.contacts.is_muted($0.pubkey) }
}
-
- func handle_unlike_event(_ ev: NostrEvent) {
- guard ev.is_valid, let privkey = self.damus_state.keypair.privkey, let e = ev.last_refid() else {
- return
- }
-
- let delete = make_delete_event(pubkey: damus_state.keypair.pubkey, privkey: privkey, deleted_events: [ev.id])
-
- pool.send(.event(delete))
-
- damus_state.likes.remove_event(ev, target: e.ref_id)
- }
+ func handle_delete_event(_ ev: NostrEvent) {
+ guard ev.is_valid else {
+ return
+ }
+
+ self.deleted_events.insert(ev.id)
+ }
func handle_contact_event(sub_id: String, relay_id: String, ev: NostrEvent) {
process_contact_event(state: self.damus_state, ev: ev)
diff --git a/damus/Models/LikeCounter.swift b/damus/Models/LikeCounter.swift
@@ -49,17 +49,4 @@ class EventCounter {
return .success(counts[target]!)
}
-
- func remove_event(_ ev: NostrEvent, target: String) {
- let pubkey = ev.pubkey
-
- user_events[pubkey]?.remove(target)
-
- if counts[target] == nil {
- counts[target] = 0
- return
- }
-
- counts[target]! -= 1
- }
}
diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift
@@ -578,16 +578,6 @@ func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> Nost
return ev
}
-func make_delete_event(pubkey: String, privkey: String, deleted_events: Set<String>) -> NostrEvent {
-
- let tags: [[String]] = deleted_events.map{["e", $0]}
-
- let ev = NostrEvent(content: "Content delete", pubkey: pubkey, kind: NostrKind.delete.rawValue, tags: tags)
- ev.calculate_id()
- ev.sign(privkey: privkey)
- return ev
-}
-
func zap_target_to_tags(_ target: ZapTarget) -> [[String]] {
switch target {
case .profile(let pk):
diff --git a/damus/Views/ActionBar/EventActionBar.swift b/damus/Views/ActionBar/EventActionBar.swift
@@ -120,15 +120,6 @@ struct EventActionBar: View {
self.bar.our_like = liked.event
}
}
- .onReceive(handle_notify(.delete)) { delete in
- guard let deleteRequest = delete.object as? NostrEvent, deleteRequest.tags.flatMap({$0}).contains(event.id),
- deleteRequest.pubkey == damus_state.keypair.pubkey else {
- return
- }
-
- self.bar.our_like = nil
- self.bar.likes -= 1
- }
}
func send_boost() {