-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathaction.rs
241 lines (233 loc) · 8.31 KB
/
action.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
use std::path::PathBuf;
use std::{collections::HashMap, rc::Weak};
use derive_more::Display;
use dioxus_desktop::DesktopService;
use dioxus_desktop::{tao::window::WindowId, DesktopContext};
use extensions::UplinkExtension;
use uuid::Uuid;
use warp::crypto::DID;
use warp::raygun::Location;
use crate::warp_runner::ui_adapter;
use super::{
call,
identity::Identity,
notifications::NotificationKind,
route::To,
ui::{EmojiDestination, Font, Theme, ToastNotification, WindowMeta},
};
/// used exclusively by State::mutate
#[derive(Display)]
pub enum Action<'a> {
// Extensions
#[display(fmt = "RegisterExtensions")]
RegisterExtensions(HashMap<String, UplinkExtension>),
#[display(fmt = "SetExtensionEnabled")]
SetExtensionEnabled(String, bool),
// UI
#[display(fmt = "SetDevSettings {_0}")]
SetDevSettings(bool),
#[display(fmt = "SetAccentColor")]
SetAccentColor((u8, u8, u8)),
#[display(fmt = "ClearAccentColor")]
ClearAccentColor,
#[display(fmt = "WindowMeta")]
SetMeta(WindowMeta),
#[display(fmt = "ToggleSilence")]
ToggleSilence,
#[display(fmt = "ToggleMute")]
ToggleMute,
#[display(fmt = "SidebarHidden: {_0}")]
SidebarHidden(bool),
#[display(fmt = "SetOverlay")]
SetOverlay(bool),
#[display(fmt = "AddToastNotification")]
AddToastNotification(ToastNotification),
#[display(fmt = "SetTheme")]
SetTheme(Option<Theme>),
#[display(fmt = "SetFont")]
SetFont(Option<Font>),
#[display(fmt = "SetFontScale")]
SetFontScale(f32),
#[display(fmt = "TrackEmojiUsage")]
TrackEmojiUsage(String),
#[display(fmt = "SetEmojiPickerVisible")]
SetEmojiPickerVisible(bool),
#[display(fmt = "SetTransformMarkdownText")]
SetTransformMarkdownText(bool),
#[display(fmt = "SetTransformAsciiEmojis")]
SetTransformAsciiEmojis(bool),
// RemoveToastNotification,
/// Sets the active call and active media id
#[display(fmt = "AnswerCall")]
AnswerCall(Uuid),
#[display(fmt = "RejectCall")]
RejectCall(Uuid),
/// creates a Call struct and joins the call
#[display(fmt = "OfferCall")]
OfferCall(call::Call),
#[display(fmt = "EndCall")]
EndCall,
// Account
/// Sets the ID for the user.
#[display(fmt = "SetId")]
SetId(Identity),
/// adds an overlay. currently only used for demonstration purposes
#[display(fmt = "AddOverlay")]
AddOverlay(Weak<DesktopService>),
/// used for the popout player or media player
#[display(fmt = "SetPopout")]
SetCallPopout(WindowId),
#[display(fmt = "ClearCallPopout")]
ClearCallPopout(DesktopContext),
#[display(fmt = "SetDebugLogger")]
SetDebugLogger(WindowId),
#[display(fmt = "ClearDebugLogger")]
ClearDebugLogger(DesktopContext),
#[display(fmt = "AddFilePreview")]
AddFilePreview(Uuid, WindowId),
#[display(fmt = "ForgetFilePreview")]
ForgetFilePreview(Uuid),
#[display(fmt = "ClearAllPopoutWindows")]
ClearAllPopoutWindows(DesktopContext),
// Notifications
#[display(fmt = "AddNotification")]
AddNotification(NotificationKind, u32, bool),
#[display(fmt = "RemoveNotification")]
RemoveNotification(NotificationKind, u32),
#[display(fmt = "ClearNotification")]
ClearNotification(NotificationKind),
#[display(fmt = "ClearAllNotifications")]
ClearAllNotifications,
#[display(fmt = "DismissUpdate")]
DismissUpdate,
// Settings
/// Sets the selected language.
#[display(fmt = "SetLanguage")]
SetLanguage(String),
#[display(fmt = "PauseGlobalKeybinds")]
PauseGlobalKeybinds(bool), // If provided false, keybinds will be un-paused.
#[display(fmt = "ResetKeybinds")]
ResetKeybinds,
// Routes
/// Set the active route
#[display(fmt = "Navigate")]
Navigate(To),
// Requests
/// Send a new friend request
#[display(fmt = "SendRequest")]
SendRequest(Identity),
/// To be fired when a friend request you sent is accepted
#[display(fmt = "RequestAccepted")]
RequestAccepted(Identity),
/// Cancel an outgoing request
#[display(fmt = "CancelRequest")]
CancelRequest(&'a DID),
/// Accept an incoming friend request
#[display(fmt = "AcceptRequest")]
AcceptRequest(&'a Identity),
/// Deny a incoming friend request
#[display(fmt = "DenyRequest")]
DenyRequest(&'a DID),
// Friends
#[display(fmt = "RemoveFriend")]
RemoveFriend(&'a DID),
#[display(fmt = "Block")]
Block(&'a DID),
#[display(fmt = "Unblock")]
Unblock(&'a DID),
/// Handles the display of "favorite" chats
#[display(fmt = "Favorite")]
Favorite(Uuid),
#[display(fmt = "UnFavorite")]
UnFavorite(Uuid),
/// Sets the active chat to a given chat
/// chat, should_move_to_top
#[display(fmt = "ChatWith")]
ChatWith(&'a Uuid, bool),
/// Removes the active chat
#[display(fmt = "ClearActiveChat")]
ClearActiveChat,
/// Removes a chat from the sidebar, also removes the active chat if the chat being removed matches
#[display(fmt = "RemoveFromSidebar")]
RemoveFromSidebar(Uuid),
/// Adds or removes a chat from the favorites page
#[display(fmt = "ToggleFavorite")]
ToggleFavorite(&'a Uuid),
// Messaging
/// React to a given message by ID
/// conversation id, message id, reaction
#[display(fmt = "AddReaction")]
AddReaction(Uuid, Uuid, String),
/// conversation id, message id, reaction
#[display(fmt = "RemoveReaction")]
RemoveReaction(Uuid, Uuid, String),
/// Sets the destination for emoji's
#[display(fmt = "SetEmojiDestination")]
SetEmojiDestination(Option<EmojiDestination>),
/// chat id, message id
#[display(fmt = "StartReplying")]
StartReplying(&'a Uuid, &'a ui_adapter::Message),
/// Sets a draft message for the chatbar for a given chat.
#[display(fmt = "SetChatDraft")]
SetChatDraft(Uuid, String),
/// Sets a files attached to send
#[display(fmt = "SetChatAttachments")]
SetChatAttachments(Uuid, Vec<Location>),
/// Similar to SetChatAttachments, but appends to the existing attachments
#[display(fmt = "AppendChatAttachments")]
AppendChatAttachments(Uuid, Vec<PathBuf>),
/// Clear attachments on chat
#[display(fmt = "ClearChatAttachments")]
ClearChatAttachments(Uuid),
/// Clears a drafted message from a given chat.
#[display(fmt = "ClearChatDraft")]
ClearChatDraft(Uuid),
/// Clears the reply for a given chat
#[display(fmt = "CancelReply")]
CancelReply(Uuid),
/// fakes sending a message to the specified chat
/// for normal operation, warp sends a message, Uplink receives an event when that message was sent, and state is updated accordingly.
/// for mock data, warp is not used and this is needed to fake sending a message
/// (Conversation Id, message)
#[display(fmt = "MockSend")]
MockSend(Uuid, Vec<String>),
#[display(fmt = "ClearUnreads")]
ClearUnreads(Uuid),
#[display(fmt = "ClearActiveUnreads")]
ClearActiveUnreads,
#[display(fmt = "ClearAllUnreads")]
ClearAllUnreads,
#[display(fmt = "Config {_0}")]
Config(ConfigAction),
}
#[derive(Display)]
pub enum ConfigAction {
#[display(fmt = "SetDyslexicEnabled {_0}")]
SetDyslexicEnabled(bool),
#[display(fmt = "SetNotificationsEnabled {_0}")]
SetNotificationsEnabled(bool),
#[display(fmt = "SetTheme {_0}")]
SetTheme(String),
#[display(fmt = "SetOverlayEnabled {_0}")]
SetOverlayEnabled(bool),
#[display(fmt = "SetDevModeEnabled {_0}")]
SetDevModeEnabled(bool),
#[display(fmt = "SetExperimentalFeaturesEnabled {_0}")]
SetExperimentalFeaturesEnabled(bool),
#[display(fmt = "SetInterfaceSoundsEnabled {_0}")]
SetInterfaceSoundsEnabled(bool),
#[display(fmt = "SetMediaSoundsEnabled {_0}")]
SetMediaSoundsEnabled(bool),
#[display(fmt = "SetMessageSoundsEnabled {_0}")]
SetMessageSoundsEnabled(bool),
#[display(fmt = "SetFriendsNotificationsEnabled {_0}")]
SetFriendsNotificationsEnabled(bool),
#[display(fmt = "SetMessagesNotificationsEnabled {_0}")]
SetMessagesNotificationsEnabled(bool),
#[display(fmt = "SetSettingsNotificationsEnabled {_0}")]
SetSettingsNotificationsEnabled(bool),
#[display(fmt = "SetAutoEnableExtensions {_0}")]
SetAutoEnableExtensions(bool),
#[display(fmt = "SetEchoCancellation {_0}")]
SetEchoCancellation(bool),
}