From 3756c2382576f0b39641d5ad079f042fe34f11b7 Mon Sep 17 00:00:00 2001 From: Matt Wisniewski Date: Mon, 24 Jul 2023 18:58:39 -0400 Subject: [PATCH] chore(State): Includes some default values for the UI (#1042) --- Cargo.lock | 10 ++--- Cargo.toml | 2 +- common/src/state/ui.rs | 47 ++++++++++++++++++++- extensions/src/api.rs | 31 ++++++++++++++ native_extensions/emoji_selector/src/lib.rs | 1 + 5 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 extensions/src/api.rs diff --git a/Cargo.lock b/Cargo.lock index 1db9ee7af91..42039443dd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1395,7 +1395,7 @@ dependencies = [ [[package]] name = "common" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", "base64 0.20.0", @@ -2589,7 +2589,7 @@ dependencies = [ [[package]] name = "extensions" -version = "0.1.5" +version = "0.1.6" dependencies = [ "derive_more", "dioxus", @@ -3850,7 +3850,7 @@ dependencies = [ [[package]] name = "icons" -version = "0.1.5" +version = "0.1.6" dependencies = [ "dioxus", "dioxus-html", @@ -4309,7 +4309,7 @@ dependencies = [ [[package]] name = "kit" -version = "0.1.5" +version = "0.1.6" dependencies = [ "chrono", "common", @@ -9107,7 +9107,7 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "uplink" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", "arboard", diff --git a/Cargo.toml b/Cargo.toml index e3c1e06aa10..5c144ee7867 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/common/src/state/ui.rs b/common/src/state/ui.rs index 10fc59aa11f..a9b70f93bee 100644 --- a/common/src/state/ui.rs +++ b/common/src/state/ui.rs @@ -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 @@ -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. @@ -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)] diff --git a/extensions/src/api.rs b/extensions/src/api.rs new file mode 100644 index 00000000000..596a1860398 --- /dev/null +++ b/extensions/src/api.rs @@ -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 + } +} diff --git a/native_extensions/emoji_selector/src/lib.rs b/native_extensions/emoji_selector/src/lib.rs index f4c2ca38440..149fcfcc556 100644 --- a/native_extensions/emoji_selector/src/lib.rs +++ b/native_extensions/emoji_selector/src/lib.rs @@ -109,6 +109,7 @@ fn build_nav(cx: Scope) -> Element<'a> { } })) } + #[inline_props] fn render_selector<'a>( cx: Scope,