Skip to content

Commit

Permalink
Restore click logic in HistoryCard
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbejar committed Jul 22, 2024
1 parent 5ec35d1 commit f3636b8
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/chat/chat_history_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,6 @@ impl Widget for ChatHistoryCard {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
self.view.handle_event(cx, event, scope);
self.widget_match_event(cx, event, scope);

let store = scope.data.get_mut::<Store>().unwrap();
let widget_uid = self.widget_uid();
if let Hit::FingerDown(fd) = event.hits_with_capture_overload(cx, self.view.area(), true) {
if fd.tap_count == 1 {
cx.widget_action(
widget_uid,
&scope.path,
ChatHistoryCardAction::ChatSelected(self.chat_id),
);
store.select_chat(self.chat_id);
self.redraw(cx);
}
}
}

fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
Expand Down Expand Up @@ -188,7 +174,7 @@ impl Widget for ChatHistoryCard {

impl WidgetMatchEvent for ChatHistoryCard {
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions, scope: &mut Scope) {
//let store = scope.data.get_mut::<Store>().unwrap();
let store = scope.data.get_mut::<Store>().unwrap();
let widget_uid = self.widget_uid();

if self.button(id!(delete_chat)).clicked(actions) {
Expand All @@ -204,6 +190,18 @@ impl WidgetMatchEvent for ChatHistoryCard {
);
return;
}

if let Some(fe) = self.view(id!(content)).finger_down(actions) {
if fe.tap_count == 1 {
cx.widget_action(
widget_uid,
&scope.path,
ChatHistoryCardAction::ChatSelected(self.chat_id),
);
store.select_chat(self.chat_id);
self.redraw(cx);
}
}
}
}

Expand Down

0 comments on commit f3636b8

Please sign in to comment.