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    PublishFinished {
70        message_id: String,
71        chat_id: String,
72        success: bool,
73    },
74    AttachmentUploadFinished {
75        chat_id: String,
76        result: Result<String, String>,
77    },
78    GroupPictureUploadFinished {
79        group_id: String,
80        result: Result<String, String>,
81    },
82    ProfilePictureUploadFinished {
83        result: Result<String, String>,
84    },
85    SyncComplete,
86}