forge
Explore
Log in

Don't you dare go Hollow

Clicking the open chat reloaded it

Browse files at this commit

a72cea7b5b32b66cc800f63fbf291ff42b3e7832Ahmet Kaan GümüşParent: 2d45643
  • fix
    • clicking the open chat reloaded it
    • select_community is the single entry and returns early when that chat is already shown (also switches to the chat view itself)
Show full message
🐛 fix: clicking the open chat reloaded it; select_community is the single entry and returns early when that chat is already shown (also switches to the chat view itself)
crates/client/src/gui/builder/communities.rsmodified+2 -5
@@ -16,9 +16,7 @@ use super::{
16 ui::{card, confirmed, icon_button, list_row, pill, rows_body},16 ui::{card, confirmed, icon_button, list_row, pill, rows_body},
17 };17 };
18 use crate::gui::{18 use crate::gui::{
19- Palette, Yumush, avatar,19+ Palette, Yumush, avatar, community_icon, entity_action, notify_error,
20- chat::View,
21- community_icon, entity_action, notify_error,
22 parts::{self, Press},20 parts::{self, Press},
23 profile::user_link,21 profile::user_link,
24 style::{radius, size, space, text},22 style::{radius, size, space, text},
@@ -251,7 +249,7 @@ impl Yumush {
251 ) {249 ) {
252 let community_id = community.id;250 let community_id = community.id;
253 if self.chat.joined(community_id) {251 if self.chat.joined(community_id) {
254- self.go_to_community(community_id, window, cx);252+ self.select_community(community_id, window, cx);
255 } else {253 } else {
256 self.open_builder_community(community, window, cx);254 self.open_builder_community(community, window, cx);
257 }255 }
@@ -270,7 +268,6 @@ impl Yumush {
270 if !self.chat.joined(community_id) {268 if !self.chat.joined(community_id) {
271 self.chat.opened = Some(community);269 self.chat.opened = Some(community);
272 }270 }
273- self.show_view(View::Chat, window, cx);
274 self.select_community(community_id, window, cx);271 self.select_community(community_id, window, cx);
275 }272 }
276 273
crates/client/src/gui/chat.rsmodified+4 -0
@@ -2010,6 +2010,10 @@ impl Yumush {
2010 window: &mut Window,2010 window: &mut Window,
2011 cx: &mut Context<Self>,2011 cx: &mut Context<Self>,
2012 ) {2012 ) {
2013+ if self.chat.view == View::Chat && self.chat.is_selected(community_id) {
2014+ return;
2015+ }
2016+ self.show_view(View::Chat, window, cx);
2013 self.stop_playing(cx);2017 self.stop_playing(cx);
2014 self.save_draft(cx);2018 self.save_draft(cx);
2015 self.chat.select(Some(community_id));2019 self.chat.select(Some(community_id));
crates/client/src/gui/dock.rsmodified+2 -2
@@ -62,7 +62,7 @@ impl Yumush {
62 let go_id = community.id;62 let go_id = community.id;
63 let actions = CallActions {63 let actions = CallActions {
64 go: Rc::new(entity_action(entity, move |yumush, window, cx| {64 go: Rc::new(entity_action(entity, move |yumush, window, cx| {
65- yumush.go_to_community(go_id, window, cx);65+ yumush.select_community(go_id, window, cx);
66 })),66 })),
67 mute: Rc::new(entity_action(entity, |yumush, window, cx| {67 mute: Rc::new(entity_action(entity, |yumush, window, cx| {
68 yumush.toggle_mute(window, cx)68 yumush.toggle_mute(window, cx)
@@ -81,7 +81,7 @@ impl Yumush {
81 cx.notify();81 cx.notify();
82 })),82 })),
83 stats: Rc::new(entity_action(entity, move |yumush, window, cx| {83 stats: Rc::new(entity_action(entity, move |yumush, window, cx| {
84- yumush.go_to_community(go_id, window, cx);84+ yumush.select_community(go_id, window, cx);
85 yumush.toggle_stats(super::chat::StatsAt::Dock);85 yumush.toggle_stats(super::chat::StatsAt::Dock);
86 cx.notify();86 cx.notify();
87 })),87 })),
crates/client/src/gui/jump.rsmodified+1 -4
@@ -399,10 +399,7 @@ impl Yumush {
399 399
400 fn go_place(&mut self, place: Place, window: &mut Window, cx: &mut Context<Self>) {400 fn go_place(&mut self, place: Place, window: &mut Window, cx: &mut Context<Self>) {
401 match place {401 match place {
402- Place::Room(id) => {402+ Place::Room(id) => self.select_community(id, window, cx),
403- self.show_view(View::Chat, window, cx);
404- self.select_community(id, window, cx);
405- }
406 Place::Person(id) => {403 Place::Person(id) => {
407 self.show_view(View::Chat, window, cx);404 self.show_view(View::Chat, window, cx);
408 self.open_direct(id, window, cx);405 self.open_direct(id, window, cx);
crates/client/src/gui/share_view.rsmodified+0 -1
@@ -683,7 +683,6 @@ impl Yumush {
683 if std::mem::take(&mut yumush.chat.float.moved) {683 if std::mem::take(&mut yumush.chat.float.moved) {
684 return;684 return;
685 }685 }
686- yumush.chat.view = View::Chat;
687 yumush.select_community(community, window, cx);686 yumush.select_community(community, window, cx);
688 })687 })
689 })688 })
crates/client/src/gui/sidebar.rsmodified+0 -13
@@ -263,19 +263,6 @@ impl Yumush {
263 .into_any_element()263 .into_any_element()
264 }264 }
265 265
266- pub(super) fn go_to_community(
267- &mut self,
268- community_id: Id,
269- window: &mut Window,
270- cx: &mut Context<Self>,
271- ) {
272- if self.chat.view == View::Chat && self.chat.is_selected(community_id) {
273- return;
274- }
275- self.show_view(View::Chat, window, cx);
276- self.select_community(community_id, window, cx);
277- }
278-
279 pub(super) fn new_community(&mut self, window: &mut Window, cx: &mut Context<Self>) {266 pub(super) fn new_community(&mut self, window: &mut Window, cx: &mut Context<Self>) {
280 input_dialog(267 input_dialog(
281 w().sidebar.new_community,268 w().sidebar.new_community,