Skip to main content

iris_chat_core/
actions.rs

1use crate::state::{OutgoingAttachment, Screen};
2
3#[derive(uniffi::Enum, Clone, Debug)]
4pub enum AppAction {
5    CreateAccount {
6        name: String,
7    },
8    UpdateProfileMetadata {
9        name: String,
10        picture_url: Option<String>,
11    },
12    RestoreSession {
13        owner_nsec: String,
14    },
15    RestoreAccountBundle {
16        owner_nsec: Option<String>,
17        owner_pubkey_hex: String,
18        device_nsec: String,
19    },
20    StartLinkedDevice {
21        owner_input: String,
22    },
23    AppForegrounded,
24    Logout,
25    CreateChat {
26        peer_input: String,
27    },
28    CreateGroup {
29        name: String,
30        member_inputs: Vec<String>,
31    },
32    CreateGroupWithPicture {
33        name: String,
34        member_inputs: Vec<String>,
35        picture_file_path: String,
36        picture_filename: String,
37    },
38    CreatePublicInvite,
39    AcceptInvite {
40        invite_input: String,
41    },
42    OpenChat {
43        chat_id: String,
44    },
45    SendMessage {
46        chat_id: String,
47        text: String,
48    },
49    SendDisappearingMessage {
50        chat_id: String,
51        text: String,
52        expires_at_secs: u64,
53    },
54    SetChatMessageTtl {
55        chat_id: String,
56        ttl_seconds: Option<u64>,
57    },
58    SetChatMuted {
59        chat_id: String,
60        muted: bool,
61    },
62    SetChatPinned {
63        chat_id: String,
64        pinned: bool,
65    },
66    SetChatUnread {
67        chat_id: String,
68        unread: bool,
69    },
70    SendAttachment {
71        chat_id: String,
72        file_path: String,
73        filename: String,
74        caption: String,
75    },
76    SendAttachments {
77        chat_id: String,
78        attachments: Vec<OutgoingAttachment>,
79        caption: String,
80    },
81    ToggleReaction {
82        chat_id: String,
83        message_id: String,
84        emoji: String,
85    },
86    SendTyping {
87        chat_id: String,
88    },
89    StopTyping {
90        chat_id: String,
91    },
92    SetTypingIndicatorsEnabled {
93        enabled: bool,
94    },
95    SetReadReceiptsEnabled {
96        enabled: bool,
97    },
98    SetDesktopNotificationsEnabled {
99        enabled: bool,
100    },
101    SetInviteAcceptanceNotificationsEnabled {
102        enabled: bool,
103    },
104    SetStartupAtLoginEnabled {
105        enabled: bool,
106    },
107    SetNearbyBluetoothEnabled {
108        enabled: bool,
109    },
110    SetNearbyLanEnabled {
111        enabled: bool,
112    },
113    SetDebugLoggingEnabled {
114        enabled: bool,
115    },
116    SetAcceptUnknownDirectMessages {
117        enabled: bool,
118    },
119    AddNostrRelay {
120        relay_url: String,
121    },
122    UpdateNostrRelay {
123        old_relay_url: String,
124        new_relay_url: String,
125    },
126    RemoveNostrRelay {
127        relay_url: String,
128    },
129    SetNostrRelays {
130        relay_urls: Vec<String>,
131    },
132    ResetNostrRelays,
133    SetImageProxyEnabled {
134        enabled: bool,
135    },
136    SetImageProxyUrl {
137        url: String,
138    },
139    SetImageProxyKeyHex {
140        key_hex: String,
141    },
142    SetImageProxySaltHex {
143        salt_hex: String,
144    },
145    ResetImageProxySettings,
146    SetMobilePushServerUrl {
147        url: String,
148    },
149    ResetMobilePushServerUrl,
150    IngestMobilePushPayload {
151        payload_json: String,
152    },
153    MarkMessagesSeen {
154        chat_id: String,
155        message_ids: Vec<String>,
156    },
157    SendReceipt {
158        chat_id: String,
159        receipt_type: String,
160        message_ids: Vec<String>,
161    },
162    DeleteLocalMessage {
163        chat_id: String,
164        message_id: String,
165    },
166    DeleteChat {
167        chat_id: String,
168    },
169    UpdateGroupName {
170        group_id: String,
171        name: String,
172    },
173    UpdateGroupPicture {
174        group_id: String,
175        file_path: String,
176        filename: String,
177    },
178    AddGroupMembers {
179        group_id: String,
180        member_inputs: Vec<String>,
181    },
182    SetGroupAdmin {
183        group_id: String,
184        owner_pubkey_hex: String,
185        is_admin: bool,
186    },
187    RemoveGroupMember {
188        group_id: String,
189        owner_pubkey_hex: String,
190    },
191    UploadProfilePicture {
192        file_path: String,
193    },
194    AddAuthorizedDevice {
195        device_input: String,
196    },
197    RemoveAuthorizedDevice {
198        device_pubkey_hex: String,
199    },
200    AcknowledgeRevokedDevice,
201    PushScreen {
202        screen: Screen,
203    },
204    UpdateScreenStack {
205        stack: Vec<Screen>,
206    },
207    // Pop the top of the navigation stack. Replaces "UI reads the
208    // stack, computes the pop, dispatches UpdateScreenStack with the
209    // new array" — the core owns the screen stack, the UI just signals
210    // the intent. Appended at the end of the enum so adding it doesn't
211    // shift existing variants' uniffi tags on still-stale bindings.
212    NavigateBack,
213    /// Persist the unsent composer text for a chat. Shells dispatch
214    /// this on composer change (debounced) and on send-or-leave so
215    /// the draft survives navigation, app suspend, and relaunch —
216    /// same shape as Signal's `updateWithDraft`. Empty string clears.
217    SetChatDraft {
218        chat_id: String,
219        text: String,
220    },
221}