Skip to main content

iris_chat_core/
updates.rs

1use crate::actions::AppAction;
2use crate::state::AppState;
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    Shutdown(Option<Sender<()>>),
37}
38
39#[derive(Debug)]
40pub(crate) enum InternalEvent {
41    RelayEvent(Event),
42    NearbyEvent(Event),
43    FetchTrackedPeerCatchUp,
44    ProtocolSubscriptionLivenessCheck {
45        token: u64,
46    },
47    PollPendingDeviceInvites {
48        token: u64,
49    },
50    PruneExpiredMessages {
51        token: u64,
52    },
53    FetchCatchUpEvents(Vec<Event>),
54    RelayStatusChanged {
55        relay_url: String,
56        status: RelayStatus,
57    },
58    RelayConnectionChecked {
59        reason: String,
60    },
61    DebugLog {
62        category: String,
63        detail: String,
64    },
65    TypingIndicatorExpired {
66        chat_id: String,
67        author: String,
68    },
69    RelayPublishFinished {
70        event_id: String,
71        message_id: Option<String>,
72        chat_id: Option<String>,
73        success: bool,
74        relay_urls: Vec<String>,
75        detail: String,
76    },
77    AttachmentUploadFinished {
78        chat_id: String,
79        result: Result<String, String>,
80    },
81    GroupPictureUploadFinished {
82        group_id: String,
83        result: Result<String, String>,
84    },
85    ProfilePictureUploadFinished {
86        result: Result<String, String>,
87    },
88    SyncComplete,
89}