1use crate::actions::AppAction;
2use crate::state::{AppState, PeerProfileDebugSnapshot};
3use flume::Sender;
4use nostr_sdk::prelude::{Event, RelayStatus};
5
6#[derive(uniffi::Enum, Clone, Debug)]
7#[allow(clippy::large_enum_variant)]
8pub enum AppUpdate {
9 FullState(AppState),
10 PersistAccountBundle {
11 rev: u64,
12 owner_nsec: Option<String>,
13 owner_pubkey_hex: String,
14 device_nsec: String,
15 },
16 NearbyPublishedEvent {
17 event_id: String,
18 kind: u32,
19 created_at_secs: u64,
20 event_json: String,
21 },
22}
23
24#[derive(Debug)]
25pub(crate) enum CoreMsg {
26 Action(AppAction),
27 Internal(Box<InternalEvent>),
28 BuildNearbyPresenceEvent {
29 peer_id: String,
30 my_nonce: String,
31 their_nonce: String,
32 profile_event_id: String,
33 reply_tx: Sender<String>,
34 },
35 ExportSupportBundle(Sender<String>),
36 PeerProfileDebug {
37 owner_input: String,
38 reply_tx: Sender<Option<PeerProfileDebugSnapshot>>,
39 },
40 PrepareForSuspend(Sender<()>),
41 CorePerfCounters(Sender<CorePerfCountersSnapshot>),
46 Shutdown(Option<Sender<()>>),
47}
48
49#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
50pub(crate) struct CorePerfCountersSnapshot {
51 pub debug_snapshot_builds: u64,
53}
54
55#[derive(Debug)]
56pub(crate) enum InternalEvent {
57 RelayEvent(Event),
58 NearbyEvent {
59 event: Event,
60 transport: String,
61 },
62 FetchTrackedPeerCatchUp {
63 token: u64,
64 },
65 ProtocolSubscriptionLivenessCheck {
66 token: u64,
67 },
68 PollPendingDeviceInvites {
69 token: u64,
70 },
71 PruneExpiredMessages {
72 token: u64,
73 },
74 FetchCatchUpEvents(Vec<Event>),
75 RelayStatusChanged {
76 relay_url: String,
77 status: RelayStatus,
78 generation: u64,
79 },
80 ProtocolSubscriptionReconcileCompleted {
81 generation: u64,
82 token: u64,
83 reason: String,
84 plan: Option<crate::core::ProtocolSubscriptionPlan>,
85 success: bool,
86 error: Option<String>,
87 relay_statuses: Vec<(String, RelayStatus)>,
88 connected_before: u64,
89 connected_after: u64,
90 filter_count: u64,
91 },
92 RelayTransportConnectionFinished {
93 token: u64,
94 reason: String,
95 relay_statuses: Vec<(String, RelayStatus)>,
96 connected_count: u64,
97 },
98 #[cfg(not(target_os = "ios"))]
99 DebugSnapshotWriteFinished {
100 generation: u64,
101 },
102 DebugLog {
103 category: String,
104 detail: String,
105 },
106 TypingIndicatorExpired {
107 chat_id: String,
108 author: String,
109 },
110 RelayPublishDrainFinished {
111 token: u64,
112 results: Vec<RelayPublishDrainResult>,
113 },
114 RetryPendingRelayPublishes {
115 reason: String,
116 },
117 AttachmentUploadFinished {
118 chat_id: String,
119 result: Result<String, String>,
120 },
121 ProfilePictureUploadFinished {
122 result: Result<String, String>,
123 },
124 SyncComplete,
125 OpenChatFinalize {
130 chat_id: String,
131 },
132}
133
134#[derive(Debug)]
135pub(crate) struct RelayPublishDrainResult {
136 pub(crate) event_id: String,
137 pub(crate) message_id: Option<String>,
138 pub(crate) chat_id: Option<String>,
139 pub(crate) success: bool,
140 pub(crate) relay_urls: Vec<String>,
141 pub(crate) detail: String,
142}