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        about: Option<String>,
12    },
13    RestoreSession {
14        owner_nsec: String,
15    },
16    RestoreAccountBundle {
17        owner_nsec: Option<String>,
18        owner_pubkey_hex: String,
19        device_nsec: String,
20    },
21    StartLinkedDevice {
22        owner_input: String,
23    },
24    SetCurrentDeviceLabels {
25        device_label: String,
26        client_label: String,
27    },
28    AppForegrounded,
29    Logout,
30    CreateChat {
31        peer_input: String,
32    },
33    CreateGroup {
34        name: String,
35        member_inputs: Vec<String>,
36    },
37    CreateGroupWithPicture {
38        name: String,
39        member_inputs: Vec<String>,
40        picture_file_path: String,
41        picture_filename: String,
42    },
43    CreatePublicInvite,
44    AcceptInvite {
45        invite_input: String,
46    },
47    OpenChat {
48        chat_id: String,
49    },
50    SendMessage {
51        chat_id: String,
52        text: String,
53    },
54    SendDisappearingMessage {
55        chat_id: String,
56        text: String,
57        expires_at_secs: u64,
58    },
59    SetChatMessageTtl {
60        chat_id: String,
61        ttl_seconds: Option<u64>,
62    },
63    SetChatMuted {
64        chat_id: String,
65        muted: bool,
66    },
67    SetChatPinned {
68        chat_id: String,
69        pinned: bool,
70    },
71    SetChatUnread {
72        chat_id: String,
73        unread: bool,
74    },
75    SendAttachment {
76        chat_id: String,
77        file_path: String,
78        filename: String,
79        caption: String,
80    },
81    SendAttachments {
82        chat_id: String,
83        attachments: Vec<OutgoingAttachment>,
84        caption: String,
85    },
86    ToggleReaction {
87        chat_id: String,
88        message_id: String,
89        emoji: String,
90    },
91    SendTyping {
92        chat_id: String,
93    },
94    StopTyping {
95        chat_id: String,
96    },
97    SetTypingIndicatorsEnabled {
98        enabled: bool,
99    },
100    SetReadReceiptsEnabled {
101        enabled: bool,
102    },
103    SetDesktopNotificationsEnabled {
104        enabled: bool,
105    },
106    SetInviteAcceptanceNotificationsEnabled {
107        enabled: bool,
108    },
109    SetStartupAtLoginEnabled {
110        enabled: bool,
111    },
112    SetNearbyEnabled {
113        enabled: bool,
114    },
115    SetNearbyBluetoothEnabled {
116        enabled: bool,
117    },
118    SetNearbyLanEnabled {
119        enabled: bool,
120    },
121    SetDebugLoggingEnabled {
122        enabled: bool,
123    },
124    SetAcceptUnknownDirectMessages {
125        enabled: bool,
126    },
127    /// Block / unblock a peer owner (Signal-style global blocklist).
128    /// When blocked, the core drops the peer from both the nostr
129    /// relay subscription and the mobile push subscription, refuses
130    /// outgoing sends, and hides their thread / discards their
131    /// incoming messages.
132    SetUserBlocked {
133        owner_pubkey_hex: String,
134        blocked: bool,
135    },
136    /// Mark a direct chat's peer as accepted (Signal whitelist). The
137    /// projection's `is_request` flag flips to false. Sending the
138    /// first outgoing message also implicitly accepts.
139    SetMessageRequestAccepted {
140        chat_id: String,
141    },
142    /// Pause / resume the nearby mailbag's store-and-forward writer
143    /// and reader. The bag's existing contents survive the toggle so
144    /// the user can flip it back on without losing what was queued;
145    /// wiping is a separate, shell-local "Empty mailbag" action that
146    /// targets the platform's nearby service directly.
147    SetNearbyMailbagEnabled {
148        enabled: bool,
149    },
150    SetNearbyShowInChatList {
151        enabled: bool,
152    },
153    AddNostrRelay {
154        relay_url: String,
155    },
156    UpdateNostrRelay {
157        old_relay_url: String,
158        new_relay_url: String,
159    },
160    RemoveNostrRelay {
161        relay_url: String,
162    },
163    SetNostrRelays {
164        relay_urls: Vec<String>,
165    },
166    ResetNostrRelays,
167    SetImageProxyEnabled {
168        enabled: bool,
169    },
170    SetImageProxyUrl {
171        url: String,
172    },
173    SetImageProxyKeyHex {
174        key_hex: String,
175    },
176    SetImageProxySaltHex {
177        salt_hex: String,
178    },
179    ResetImageProxySettings,
180    SetMobilePushServerUrl {
181        url: String,
182    },
183    ResetMobilePushServerUrl,
184    IngestMobilePushPayload {
185        payload_json: String,
186    },
187    MarkMessagesSeen {
188        chat_id: String,
189        message_ids: Vec<String>,
190    },
191    SendReceipt {
192        chat_id: String,
193        receipt_type: String,
194        message_ids: Vec<String>,
195    },
196    DeleteLocalMessage {
197        chat_id: String,
198        message_id: String,
199    },
200    DeleteChat {
201        chat_id: String,
202    },
203    UpdateGroupName {
204        group_id: String,
205        name: String,
206    },
207    UpdateGroupPicture {
208        group_id: String,
209        file_path: String,
210        filename: String,
211    },
212    /// Admin: set or clear the group's free-text description (Signal's group
213    /// description). `None` clears.
214    UpdateGroupAbout {
215        group_id: String,
216        about: Option<String>,
217    },
218    AddGroupMembers {
219        group_id: String,
220        member_inputs: Vec<String>,
221    },
222    SetGroupAdmin {
223        group_id: String,
224        owner_pubkey_hex: String,
225        is_admin: bool,
226    },
227    RemoveGroupMember {
228        group_id: String,
229        owner_pubkey_hex: String,
230    },
231    UploadProfilePicture {
232        file_path: String,
233    },
234    AddAuthorizedDevice {
235        device_input: String,
236    },
237    RemoveAuthorizedDevice {
238        device_pubkey_hex: String,
239    },
240    AcknowledgeRevokedDevice,
241    PushScreen {
242        screen: Screen,
243    },
244    UpdateScreenStack {
245        stack: Vec<Screen>,
246    },
247    // Pop the top of the navigation stack. Replaces "UI reads the
248    // stack, computes the pop, dispatches UpdateScreenStack with the
249    // new array" — the core owns the screen stack, the UI just signals
250    // the intent. Appended at the end of the enum so adding it doesn't
251    // shift existing variants' uniffi tags on still-stale bindings.
252    NavigateBack,
253    /// Persist the unsent composer text for a chat. Shells dispatch
254    /// this on composer change (debounced) and on send-or-leave so
255    /// the draft survives navigation, app suspend, and relaunch —
256    /// same shape as Signal's `updateWithDraft`. Empty string clears.
257    SetChatDraft {
258        chat_id: String,
259        text: String,
260    },
261    /// Publish a blank owner metadata event so public profile name/photo are
262    /// cleared before the shell removes local keys and data.
263    DeleteProfileMetadata,
264    /// Set or clear a local nickname for a contact. Appended at the end of
265    /// the enum so adding it doesn't shift existing variants' uniffi tags
266    /// on still-stale bindings.
267    SetContactNickname {
268        owner_pubkey_hex: String,
269        nickname: String,
270    },
271}