Skip to main content

iris_chat_core/
updates.rs

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    Shutdown(Option<Sender<()>>),
42}
43
44#[derive(Debug)]
45pub(crate) enum InternalEvent {
46    RelayEvent(Event),
47    NearbyEvent {
48        event: Event,
49        transport: String,
50    },
51    FetchTrackedPeerCatchUp,
52    ProtocolSubscriptionLivenessCheck {
53        token: u64,
54    },
55    PollPendingDeviceInvites {
56        token: u64,
57    },
58    PruneExpiredMessages {
59        token: u64,
60    },
61    FetchCatchUpEvents(Vec<Event>),
62    RelayStatusChanged {
63        relay_url: String,
64        status: RelayStatus,
65        generation: u64,
66    },
67    ProtocolSubscriptionReconcileCompleted {
68        generation: u64,
69        token: u64,
70        reason: String,
71        plan: Option<crate::core::ProtocolSubscriptionPlan>,
72        success: bool,
73        error: Option<String>,
74        relay_statuses: Vec<(String, RelayStatus)>,
75        connected_before: u64,
76        connected_after: u64,
77        filter_count: u64,
78    },
79    RelayTransportConnectionFinished {
80        token: u64,
81        reason: String,
82        relay_statuses: Vec<(String, RelayStatus)>,
83        connected_count: u64,
84    },
85    #[cfg(not(target_os = "ios"))]
86    DebugSnapshotWriteFinished {
87        generation: u64,
88    },
89    DebugLog {
90        category: String,
91        detail: String,
92    },
93    TypingIndicatorExpired {
94        chat_id: String,
95        author: String,
96    },
97    RelayPublishDrainFinished {
98        token: u64,
99        results: Vec<RelayPublishDrainResult>,
100    },
101    RetryPendingRelayPublishes {
102        reason: String,
103    },
104    AttachmentUploadFinished {
105        chat_id: String,
106        result: Result<String, String>,
107    },
108    ProfilePictureUploadFinished {
109        result: Result<String, String>,
110    },
111    SyncComplete,
112}
113
114#[derive(Debug)]
115pub(crate) struct RelayPublishDrainResult {
116    pub(crate) event_id: String,
117    pub(crate) message_id: Option<String>,
118    pub(crate) chat_id: Option<String>,
119    pub(crate) success: bool,
120    pub(crate) relay_urls: Vec<String>,
121    pub(crate) detail: String,
122}