forge
Explore
Log in

Don't you dare go Hollow

Calling from a DM without messages (regressed in 5ab0425): is_direct now also sees the opened, unlisted DM so the Call button shows, and the callee rings when the call reveals a DM it didn't know yet. ✨ feat: emoji picker on the Settings status field

Browse files at this commit

b16b8f66c5721daaa3d8fd83ef9e63870f00d997Ahmet Kaan GümüşParent: 14a11c9
  • fix
    • calling from a DM without messages (regressed in 5ab0425): is_direct now also sees the opened, unlisted DM so the Call button shows, and the callee rings when the call reveals a DM it didn't know yet. ✨ feat: emoji picker on the Settings status field
    • one glyph::insert_into for composer, profile card and settings
Show full message
🐛 fix: calling from a DM without messages (regressed in 5ab0425): is_direct now also sees the opened, unlisted DM so the Call button shows, and the callee rings when the call reveals a DM it didn't know yet. ✨ feat: emoji picker on the Settings status field; one glyph::insert_into for composer, profile card and settings
crates/client/src/gui.rsmodified+2 -4
@@ -1169,13 +1169,11 @@ impl Yumush {
1169 1169
1170 pub(super) fn is_direct(&self, community_id: Id) -> bool {1170 pub(super) fn is_direct(&self, community_id: Id) -> bool {
1171 self.chat1171 self.chat
1172- .communities()1172+ .community(community_id)
1173- .iter()
1174- .find(|community| community.id == community_id)
1175 .is_some_and(|community| community.kind.is_direct())1173 .is_some_and(|community| community.kind.is_direct())
1176 }1174 }
1177 1175
1178- fn is_me(&self, user_id: Id) -> bool {1176+ pub(super) fn is_me(&self, user_id: Id) -> bool {
1179 self.user.as_ref().is_some_and(|me| me.id == user_id)1177 self.user.as_ref().is_some_and(|me| me.id == user_id)
1180 }1178 }
1181 1179
crates/client/src/gui/chat.rsmodified+21 -14
@@ -1069,7 +1069,7 @@ impl Chat {
1069 }1069 }
1070 }1070 }
1071 1071
1072- fn community(&self, community_id: Id) -> Option<&Community> {1072+ pub fn community(&self, community_id: Id) -> Option<&Community> {
1073 self.communities1073 self.communities
1074 .iter()1074 .iter()
1075 .chain(self.opened.as_ref())1075 .chain(self.opened.as_ref())
@@ -2073,19 +2073,7 @@ impl Yumush {
2073 "composer_emoji",2073 "composer_emoji",
2074 &entity,2074 &entity,
2075 palette,2075 palette,
2076- std::rc::Rc::new({2076+ super::glyph::insert_into(self.chat.message_input.clone()),
2077- let entity = entity.clone();
2078- move |emoji, window, cx| {
2079- entity.update(cx, |yumush, cx| {
2080- let input = yumush.chat.message_input.clone();
2081- input.update(cx, |state, cx| {
2082- state.insert(emoji, window, cx);
2083- state.focus(window, cx);
2084- });
2085- input.update(cx, |state, cx| state.mark(cx));
2086- })
2087- }
2088- }),
2089 ))2077 ))
2090 .when(!ready, |this| {2078 .when(!ready, |this| {
2091 this.child(voice_note::mic_button(&entity, palette))2079 this.child(voice_note::mic_button(&entity, palette))
@@ -2182,7 +2170,26 @@ impl Yumush {
2182 return;2170 return;
2183 };2171 };
2184 let _ = this.update(cx, |yumush, cx| {2172 let _ = this.update(cx, |yumush, cx| {
2173+ let known: HashSet<Id> = yumush.chat.communities.iter().map(|c| c.id).collect();
2185 yumush.chat.replace_communities(communities);2174 yumush.chat.replace_communities(communities);
2175+ let calls: Vec<Id> = yumush
2176+ .chat
2177+ .communities
2178+ .iter()
2179+ .filter(|community| !known.contains(&community.id))
2180+ .filter(|community| {
2181+ community.kind.is_direct()
2182+ && !yumush.chat.in_voice(community.id)
2183+ && yumush
2184+ .chat
2185+ .voice_ids(community.id)
2186+ .iter()
2187+ .any(|id| !yumush.is_me(*id))
2188+ })
2189+ .map(|community| community.id)
2190+ .collect();
2191+ yumush.chat.ringing.extend(calls);
2192+ yumush.update_ringing(cx);
2186 yumush.request_social_avatars(cx);2193 yumush.request_social_avatars(cx);
2187 cx.notify();2194 cx.notify();
2188 });2195 });
crates/client/src/gui/community_settings.rsmodified+1 -0
@@ -132,6 +132,7 @@ impl Yumush {
132 input: &self.chat.community_name_input,132 input: &self.chat.community_name_input,
133 current: &name,133 current: &name,
134 save: Yumush::save_community_name,134 save: Yumush::save_community_name,
135+ emoji: None,
135 },136 },
136 entity,137 entity,
137 palette,138 palette,
crates/client/src/gui/glyph.rsmodified+15 -0
@@ -110,6 +110,9 @@ pub trait Fill {
110 fn mark(&mut self, cx: &mut Context<Self>)110 fn mark(&mut self, cx: &mut Context<Self>)
111 where111 where
112 Self: Sized;112 Self: Sized;
113+ fn put(&mut self, emoji: &'static str, window: &mut Window, cx: &mut Context<Self>)
114+ where
115+ Self: Sized;
113 }116 }
114 117
115 macro_rules! fill {118 macro_rules! fill {
@@ -128,6 +131,11 @@ macro_rules! fill {
128 let content = content(&self.text().to_string());131 let content = content(&self.text().to_string());
129 let _ = self.set_tokens(content, cx);132 let _ = self.set_tokens(content, cx);
130 }133 }
134+
135+ fn put(&mut self, emoji: &'static str, window: &mut Window, cx: &mut Context<Self>) {
136+ self.insert(emoji, window, cx);
137+ self.focus(window, cx);
138+ }
131 }139 }
132 };140 };
133 }141 }
@@ -172,6 +180,13 @@ pub fn extensions() -> MarkdownExtensions {
172 180
173 pub type Pick = std::rc::Rc<dyn Fn(&'static str, &mut Window, &mut App)>;181 pub type Pick = std::rc::Rc<dyn Fn(&'static str, &mut Window, &mut App)>;
174 182
183+pub fn insert_into<T: Fill + 'static>(input: Entity<T>) -> Pick {
184+ std::rc::Rc::new(move |emoji, window, cx| {
185+ input.update(cx, |state, cx| state.put(emoji, window, cx));
186+ input.update(cx, |state, cx| state.mark(cx));
187+ })
188+}
189+
175 pub fn picker_button(190 pub fn picker_button(
176 id: &'static str,191 id: &'static str,
177 entity: &Entity<Yumush>,192 entity: &Entity<Yumush>,
crates/client/src/gui/profile.rsmodified+1 -7
@@ -429,13 +429,7 @@ impl Card {
429 "status_emoji",429 "status_emoji",
430 entity,430 entity,
431 palette,431 palette,
432- std::rc::Rc::new(move |emoji, window, cx| {432+ super::glyph::insert_into(status),
433- status.update(cx, |state, cx| {
434- state.insert(emoji, window, cx);
435- state.focus(window, cx);
436- });
437- status.update(cx, |state, cx| state.mark(cx));
438- }),
439 )),433 )),
440 );434 );
441 }435 }
crates/client/src/gui/settings_page.rsmodified+12 -0
@@ -150,6 +150,7 @@ impl Yumush {
150 input: &self.chat.username_input,150 input: &self.chat.username_input,
151 current: &user.username,151 current: &user.username,
152 save: Yumush::save_username,152 save: Yumush::save_username,
153+ emoji: None,
153 },154 },
154 entity,155 entity,
155 palette,156 palette,
@@ -162,6 +163,7 @@ impl Yumush {
162 input: &self.chat.status_input,163 input: &self.chat.status_input,
163 current: &user.status,164 current: &user.status,
164 save: Yumush::save_status,165 save: Yumush::save_status,
166+ emoji: Some("status_settings_emoji"),
165 },167 },
166 entity,168 entity,
167 palette,169 palette,
@@ -834,6 +836,7 @@ pub(super) struct Editable<'a> {
834 pub input: &'a Entity<InputState>,836 pub input: &'a Entity<InputState>,
835 pub current: &'a str,837 pub current: &'a str,
836 pub save: fn(&mut Yumush, &mut Window, &mut Context<Yumush>),838 pub save: fn(&mut Yumush, &mut Window, &mut Context<Yumush>),
839+ pub emoji: Option<&'static str>,
837 }840 }
838 841
839 pub(super) fn text_row(842 pub(super) fn text_row(
@@ -843,6 +846,14 @@ pub(super) fn text_row(
843 cx: &App,846 cx: &App,
844 ) -> Div {847 ) -> Div {
845 let dirty = editable.input.read(cx).text() != editable.current;848 let dirty = editable.input.read(cx).text() != editable.current;
849+ let picker = editable.emoji.map(|id| {
850+ super::glyph::picker_button(
851+ id,
852+ entity,
853+ palette,
854+ super::glyph::insert_into(editable.input.clone()),
855+ )
856+ });
846 let entity = entity.clone();857 let entity = entity.clone();
847 let save = editable.save;858 let save = editable.save;
848 859
@@ -862,6 +873,7 @@ pub(super) fn text_row(
862 .items_center()873 .items_center()
863 .gap(px(space::SM))874 .gap(px(space::SM))
864 .child(field(palette, editable.input).flex_1())875 .child(field(palette, editable.input).flex_1())
876+ .children(picker)
865 .when(dirty, |this| {877 .when(dirty, |this| {
866 this.child(878 this.child(
867 clickable(editable.id, palette, move |window, cx| {879 clickable(editable.id, palette, move |window, cx| {