Skip to content

Commit

Permalink
chore(State): Includes some default values for the UI (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfamousVague authored Jul 24, 2023
1 parent 2e942e2 commit 3756c23
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ opt-level = 3
codegen-units = 1

[workspace.package]
version = "0.1.5"
version = "0.1.6"
rust-version = "1.70"

[workspace.dependencies]
Expand Down
47 changes: 46 additions & 1 deletion common/src/state/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,20 @@ fn default_emojis() -> EmojiList {
])
}

#[derive(Default, Deserialize, Serialize)]
/// Used to determine where the Emoji should be routed.
#[derive(Debug, Clone, Deserialize, Serialize, Eq, PartialEq)]
pub enum EmojiDestination {
Chatbar,
Message(Uuid),
}

impl Default for EmojiDestination {
fn default() -> Self {
Self::Chatbar
}
}

#[derive(Deserialize, Serialize)]
pub struct UI {
pub notifications: Notifications,
// stores information related to the current call
Expand All @@ -77,6 +90,7 @@ pub struct UI {
pub metadata: WindowMeta,
#[serde(default = "default_emojis")]
pub emoji_list: EmojiList,
pub emoji_destination: EmojiDestination,
#[serde(skip)]
pub current_layout: Layout,
// overlays or other windows are created via DesktopContext::new_window. they are stored here so they can be closed later.
Expand All @@ -94,6 +108,37 @@ pub struct UI {
pub ignore_focus: bool,
}

impl Default for UI {
fn default() -> Self {
Self {
notifications: Default::default(),
call_info: Default::default(),
current_debug_logger: Default::default(),
popout_media_player: Default::default(),
toast_notifications: Default::default(),
accent_color: Default::default(),
theme: Default::default(),
font: Default::default(),
enable_overlay: Default::default(),
active_welcome: Default::default(),
sidebar_hidden: Default::default(),
window_maximized: Default::default(),
window_width: Default::default(),
window_height: Default::default(),
metadata: Default::default(),
emoji_list: default_emojis(),
emoji_destination: Default::default(),
current_layout: Default::default(),
overlays: Default::default(),
extensions: Default::default(),
file_previews: Default::default(),
show_settings_welcome: true,
cached_username: Default::default(),
ignore_focus: Default::default(),
}
}
}

#[derive(Default, Deserialize, Serialize)]
pub struct Extensions {
#[serde(default)]
Expand Down
31 changes: 31 additions & 0 deletions extensions/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pub struct ExtensionsAPI {
pub version: &'static str,
pub rustc_version: &'static str,
pub cargo_version: &'static str,
}

/// Extensions API base
impl ExtensionsAPI {
pub fn get_version(&self) -> &'static str {
self.version
}

pub fn get_rustc_version(&self) -> &'static str {
self.rustc_version
}

pub fn get_cargo_version(&self) -> &'static str {
self.cargo_version
}
}

/// Emoji's
impl ExtensionsAPI {
pub fn dispatch_emoji(&self) {
// does this extension have the emoji permissions
// access state
// where is the destination?
// send to chatbar
// send to message by uuid as reaction
}
}
1 change: 1 addition & 0 deletions native_extensions/emoji_selector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ fn build_nav(cx: Scope) -> Element<'a> {
}
}))
}

#[inline_props]
fn render_selector<'a>(
cx: Scope,
Expand Down

0 comments on commit 3756c23

Please sign in to comment.