Skip to content

Commit

Permalink
Merge branch 'dev' into chat_friend_request
Browse files Browse the repository at this point in the history
  • Loading branch information
phillsatellite authored Nov 6, 2023
2 parents 0466ee7 + 5814b67 commit e443bf7
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 16 deletions.
3 changes: 2 additions & 1 deletion common/locales/en-US/main.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ uplink = Uplink
.download-update = Download Update
.date-time-format = %d/%m/%Y %I:%M %p
.open-devtools = Open Console
.clear-unreads = Clear Unreads
community = Community
.invited = You're Invited!
.join = Join
Expand Down
2 changes: 2 additions & 0 deletions common/src/state/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ pub enum Action<'a> {
ClearUnreads(Uuid),
#[display(fmt = "ClearActiveUnreads")]
ClearActiveUnreads,
#[display(fmt = "ClearAllUnreads")]
ClearAllUnreads,
#[display(fmt = "Config {_0}")]
Config(ConfigAction),
}
Expand Down
1 change: 1 addition & 0 deletions common/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ impl State {
self.clear_unreads(id);
}
}
Action::ClearAllUnreads => self.chats.all.values_mut().for_each(|c| c.clear_unreads()),
Action::SetChatDraft(chat_id, value) => self.set_chat_draft(&chat_id, value),
Action::ClearChatDraft(chat_id) => self.clear_chat_draft(&chat_id),
Action::SetChatAttachments(chat_id, value) => {
Expand Down
4 changes: 2 additions & 2 deletions docs/new-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ This document contains some useful resources for anyone wishing to contribute to

## Quick Start

1. Get a TL;DR about Satellite and Uplink from [the doc](docs/what.md)
1. Get a TL;DR about Satellite and Uplink from [the doc](https://github.com/Satellite-im/Uplink/blob/dev/docs/architecture.md)

2. Ensure you run physical and automated tests before submitting a PR for review. We work really hard to have no regressions even if a new feature may be "more important".

3. Review both open and closed [issues](https://github.com/ssatellite-im/Uplink/issues), there may be others working on a similar feature.
3. Review both open and closed [issues](https://github.com/satellite-im/Uplink/issues), there may be others working on a similar feature.

4. Be aware that unless you explicitly state otherwise, contributions you make to this project will be under the licensing rights of the original author's, Satellite.im's, specified license terms (to be outlined in the repository).

Expand Down
33 changes: 26 additions & 7 deletions kit/src/components/nav/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use dioxus::prelude::*;
use uuid::Uuid;

use crate::elements::{
button::Button,
tooltip::{ArrowPosition, Tooltip},
Appearance,
use crate::{
components::context_menu::ContextMenu,
elements::{
button::Button,
tooltip::{ArrowPosition, Tooltip},
Appearance,
},
};
use common::icons::outline::Shape as Icon;
pub type To = &'static str;
Expand All @@ -16,6 +20,7 @@ pub struct Route<'a> {
pub with_badge: Option<String>,
pub loading: Option<bool>,
pub child: Option<Element<'a>>,
pub context_items: Option<Element<'a>>,
}

impl Default for Route<'_> {
Expand All @@ -27,6 +32,7 @@ impl Default for Route<'_> {
with_badge: None,
loading: None,
child: None,
context_items: None,
}
}
}
Expand Down Expand Up @@ -98,7 +104,8 @@ pub fn Nav<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
let active = use_state(cx, || get_active(&cx));
let bubble = cx.props.bubble.unwrap_or_default();
let tooltip_direction = cx.props.tooltip_direction.unwrap_or(ArrowPosition::Bottom);

// For some reason if you dont do this the first render will not have a context menu
let uuid = use_ref(cx, || Uuid::new_v4().to_string());
cx.render(rsx!(
div {
aria_label: "button-nav",
Expand All @@ -109,6 +116,7 @@ pub fn Nav<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
let badge = get_badge(route);
let key: String = route.name.clone();
let name: String = route.name.clone();
let name2: String = name.to_lowercase();
let aria_label: String = route.name.clone();
// todo: don't show the tooltip if bubble is true
let tooltip = if cx.props.bubble.is_some() {
Expand All @@ -120,7 +128,7 @@ pub fn Nav<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
}))
};

rsx!(
let btn = rsx!(
div {
position: "relative",
display: "inline-grid",
Expand All @@ -141,7 +149,18 @@ pub fn Nav<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
},
route.child.as_ref()
}
)
);
match route.context_items.as_ref() {
None => btn,
Some(items) => {
rsx!(ContextMenu{
id: format!("route-{}-{}", name2, uuid.read()),
key: "{name2}-{uuid.read()}",
items: items.clone(),
btn
})
}
}
})
}
))
Expand Down
3 changes: 3 additions & 0 deletions kit/src/elements/tooltip/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
margin-top: var(--border-radius);
top: 100%;
}
.tooltip-arrow-top-right {
right: 0;
}
.tooltip-arrow-bottom,
.tooltip-arrow-bottom-left,
.tooltip-arrow-bottom-right {
Expand Down
6 changes: 4 additions & 2 deletions ui/src/layouts/chats/presentation/sidebar/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ pub fn search_friends<'a>(cx: Scope<'a, SearchProps<'a>>) -> Element<'a> {
div {
padding_right: "32px",
aria_label: "search-result-blocked-user",
display: "flex",
IconElement {
size: 40,
fill: "var(--text-color-muted)",
icon: Icon::NoSymbol,
icon: Icon::UserBlocked,
},
}
)
Expand Down Expand Up @@ -273,11 +274,12 @@ pub fn search_friends<'a>(cx: Scope<'a, SearchProps<'a>>) -> Element<'a> {
rsx!(
div {
padding_right: "32px",
display: "flex",
aria_label: "search-result-blocked-user-in-group",
IconElement {
size: 40,
fill: "var(--text-color-muted)",
icon: Icon::NoSymbol,
icon: Icon::UserBlocked,
},
}
)
Expand Down
7 changes: 4 additions & 3 deletions ui/src/layouts/chats/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@
padding-left: 16px;
padding-bottom: 4px;
margin-bottom: 4px;
div {
margin-top: auto;
margin-bottom: auto;
}
#profile-image {
margin: var(--gap-less);
//TODO(Lucas): Look to it, should be width: var(--height-input);
Expand Down Expand Up @@ -548,9 +552,6 @@
animation: none;
}
}
.tooltip-arrow-top-right {
margin-right: 50px;
}
#compose {
.typing-indicator {
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/layouts/storage/files_layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn FilesLayout(cx: Scope<'_>) -> Element<'_> {
aria_label: "upload-file".into(),
tooltip: cx.render(rsx!(
Tooltip {
arrow_position: ArrowPosition::Top,
arrow_position: ArrowPosition::TopRight,
text: get_local_text("files.upload"),
}
)),
Expand Down
9 changes: 9 additions & 0 deletions ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,15 @@ fn AppNav<'a>(
unreads.to_string(),
}))
}),
context_items: (unreads > 0).then(|| {
cx.render(rsx!(ContextItem {
aria_label: "clear-unreads".into(),
text: get_local_text("uplink.clear-unreads"),
onpress: move |_| {
state.write().mutate(Action::ClearAllUnreads);
}
},))
}),
..UIRoute::default()
};
let settings_route = UIRoute {
Expand Down

0 comments on commit e443bf7

Please sign in to comment.