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