Fix reposts on macos

This commit is contained in:
William Casarin
2023-04-19 11:08:59 -07:00
parent d667a9d8f7
commit 88db9de4ea
9 changed files with 232 additions and 137 deletions
+3 -45
View File
@@ -77,11 +77,9 @@ struct ContentView: View {
@State var confirm_mute: Bool = false
@State var user_muted_confirm: Bool = false
@State var confirm_overwrite_mutelist: Bool = false
@State var current_boost: NostrEvent? = nil
@State var filter_state : FilterState = .posts_and_replies
@State private var isSideBarOpened = false
@StateObject var home: HomeModel = HomeModel()
@State var shouldShowBoostAlert = false
// connect retry timer
let timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect()
@@ -349,19 +347,9 @@ struct ContentView: View {
}
}
.onReceive(handle_notify(.boost)) { notif in
guard let ev = notif.object as? NostrEvent else {
return
}
current_boost = ev
shouldShowBoostAlert = true
}
.onReceive(handle_notify(.reply)) { notif in
let ev = notif.object as! NostrEvent
self.active_sheet = .post(.replying_to(ev))
}
.onReceive(handle_notify(.like)) { like in
.onReceive(handle_notify(.compose)) { notif in
let action = notif.object as! PostAction
self.active_sheet = .post(action)
}
.onReceive(handle_notify(.deleted_account)) { notif in
self.is_deleted_account = true
@@ -605,36 +593,6 @@ struct ContentView: View {
Text("Could not find user to mute...", comment: "Alert message to indicate that the muted user could not be found.")
}
})
.confirmationDialog("Repost", isPresented: $shouldShowBoostAlert) {
Button(NSLocalizedString("Repost", comment: "Title of alert for confirming to repost a post.")) {
guard let current_boost else {
return
}
guard let privkey = self.damus_state?.keypair.privkey else {
return
}
guard let damus_state else {
return
}
let boost = make_boost_event(pubkey: damus_state.keypair.pubkey, privkey: privkey, boosted: current_boost)
damus_state.postbox.send(boost)
}
Button(NSLocalizedString("Quote", comment: "Title of alert for confirming to make a quoted post.")) {
guard let current_boost else {
return
}
self.active_sheet = .post(.quoting(current_boost))
}
}
.onChange(of: shouldShowBoostAlert) { v in
if v == false {
self.current_boost = nil
}
}
}
func switch_timeline(_ timeline: Timeline) {