Files
damus/damus/Views/ActionBar/RepostAction.swift
Daniel D’Aquino 3a0acfaba1 Implement NostrNetworkManager and UserRelayListManager
This commit implements a new layer called NostrNetworkManager,
responsible for managing interactions with the Nostr network, and
providing a higher level API that is easier and more secure to use for
the layer above it.

It also integrates it with the rest of the app, by moving RelayPool and PostBox
into NostrNetworkManager, along with all their usages.

Changelog-Added: Added NIP-65 relay list support
Changelog-Changed: Improved robustness of relay list handling
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-04-16 11:48:52 -07:00

67 lines
2.2 KiB
Swift

//
// RepostAction.swift
// damus
//
// Created by William Casarin on 2023-04-19.
//
import SwiftUI
struct RepostAction: View {
let damus_state: DamusState
let event: NostrEvent
@Environment(\.dismiss) var dismiss
@Environment(\.colorScheme) var colorScheme
var body: some View {
VStack(alignment: .leading) {
Button {
dismiss()
guard let keypair = self.damus_state.keypair.to_full(),
let boost = make_boost_event(keypair: keypair, boosted: self.event) else {
return
}
damus_state.nostrNetwork.postbox.send(boost)
} label: {
Label(NSLocalizedString("Repost", comment: "Button to repost a note"), image: "repost")
.frame(maxWidth: .infinity, minHeight: 50, maxHeight: 50, alignment: .leading)
}
.font(.system(size: 20, weight: .regular))
.foregroundColor(colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite"))
.padding(EdgeInsets(top: 25, leading: 50, bottom: 0, trailing: 50))
Button {
dismiss()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
notify(.compose(.quoting(self.event)))
}
} label: {
Label(NSLocalizedString("Quote", comment: "Button to compose a quoted note"), systemImage: "quote.opening")
.frame(maxWidth: .infinity, minHeight: 50, maxHeight: 50, alignment: .leading)
}
.font(.system(size: 20, weight: .regular))
.foregroundColor(colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite"))
.padding(EdgeInsets(top: 0, leading: 50, bottom: 0, trailing: 50))
HStack {
BigButton(NSLocalizedString("Cancel", comment: "Button to cancel a repost.")) {
dismiss()
}
}
}
}
}
struct RepostAction_Previews: PreviewProvider {
static var previews: some View {
RepostAction(damus_state: test_damus_state, event: test_note)
}
}