Skip to content

Commit

Permalink
Merge branch 'dev' into fix-issue-290-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Guocork authored Nov 14, 2024
2 parents 88b13d1 + 7b4b9bb commit 230edf5
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl MatchEvent for App {
}

if matches!(
action.as_widget_action().cast(),
action.cast(),
DownloadNotificationPopupAction::ActionLinkClicked
| DownloadNotificationPopupAction::CloseButtonClicked
) {
Expand Down
2 changes: 1 addition & 1 deletion src/chat/chat_history_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl WidgetMatchEvent for ChatHistoryCard {

for action in actions {
if matches!(
action.as_widget_action().cast(),
action.cast(),
DeleteChatModalAction::Cancelled
| DeleteChatModalAction::CloseButtonClicked
| DeleteChatModalAction::ChatDeleted
Expand Down
11 changes: 5 additions & 6 deletions src/chat/delete_chat_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,27 +181,26 @@ impl Widget for DeleteChatModal {

impl WidgetMatchEvent for DeleteChatModal {
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions, scope: &mut Scope) {
let widget_uid = self.widget_uid();

if self.button(id!(close_button)).clicked(actions) {
cx.widget_action(widget_uid, &scope.path, DeleteChatModalAction::CloseButtonClicked);
cx.action(DeleteChatModalAction::CloseButtonClicked);
}

if self
.button(id!(wrapper.body.actions.delete_button))
.button(id!(delete_button))
.clicked(actions)
{
let store = scope.data.get_mut::<Store>().unwrap();
store.delete_chat(self.chat_id);
cx.widget_action(widget_uid, &scope.path, DeleteChatModalAction::ChatDeleted);
cx.action(DeleteChatModalAction::ChatDeleted);
cx.redraw_all();
}

if self
.button(id!(wrapper.body.actions.cancel_button))
.button(id!(cancel_button))
.clicked(actions)
{
cx.widget_action(widget_uid, &scope.path, DeleteChatModalAction::Cancelled);
cx.action(DeleteChatModalAction::Cancelled);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/landing/landing_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Widget for LandingScreen {
impl WidgetMatchEvent for LandingScreen {
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions, scope: &mut Scope) {
for action in actions.iter() {
match action.as_widget_action().cast() {
match action.cast() {
ModelListAction::ScrolledAtTop => {
if self.search_bar_state == SearchBarState::CollapsedWithoutFilters {
self.search_bar_state = SearchBarState::ExpandedWithoutFilters;
Expand Down
5 changes: 2 additions & 3 deletions src/landing/model_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl WidgetMatchEvent for ModelCard {
}

for action in actions {
if let ModelCardViewAllModalAction::CloseButtonClicked = action.as_widget_action().cast() {
if let ModelCardViewAllModalAction::CloseButtonClicked = action.cast() {
self.modal(id!(modal)).close(cx);
self.redraw(cx);
}
Expand Down Expand Up @@ -457,10 +457,9 @@ impl Widget for ModelCardViewAllModal {

impl WidgetMatchEvent for ModelCardViewAllModal {
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions, scope: &mut Scope) {
let widget_uid = self.widget_uid();

if self.button(id!(close_button)).clicked(actions) {
cx.widget_action(widget_uid, &scope.path, ModelCardViewAllModalAction::CloseButtonClicked);
cx.action(ModelCardViewAllModalAction::CloseButtonClicked);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/landing/model_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,12 @@ impl WidgetMatchEvent for ModelList {
}

if portal_list.scrolled(actions) {
let widget_uid = self.widget_uid();
if portal_list.first_id() == 0
&& portal_list.scroll_position() > SCROLLING_AT_TOP_THRESHOLD
{
cx.widget_action(widget_uid, &scope.path, ModelListAction::ScrolledAtTop);
cx.action(ModelListAction::ScrolledAtTop);
} else {
cx.widget_action(widget_uid, &scope.path, ModelListAction::ScrolledNotAtTop);
cx.action(ModelListAction::ScrolledNotAtTop);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/shared/download_notification_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl WidgetMatchEvent for DownloadNotificationPopup {
let widget_uid = self.widget_uid();

if self.button(id!(close_button)).clicked(actions) {
cx.widget_action(widget_uid, &scope.path, DownloadNotificationPopupAction::CloseButtonClicked);
cx.action(DownloadNotificationPopupAction::CloseButtonClicked);
}

if self
Expand All @@ -259,7 +259,7 @@ impl WidgetMatchEvent for DownloadNotificationPopup {
{
// TODO: Abstract the navigation actions on a single enum for the whole app.
cx.action(PopupAction::NavigateToMyModels);
cx.widget_action(widget_uid, &scope.path, DownloadNotificationPopupAction::ActionLinkClicked);
cx.action(DownloadNotificationPopupAction::ActionLinkClicked);
}

if self.link_label(id!(retry_link)).clicked(actions) {
Expand All @@ -269,7 +269,7 @@ impl WidgetMatchEvent for DownloadNotificationPopup {
&scope.path,
DownloadAction::Play(file_id.clone()),
);
cx.widget_action(widget_uid, &scope.path, DownloadNotificationPopupAction::ActionLinkClicked);
cx.action(DownloadNotificationPopupAction::ActionLinkClicked);
}

if self.link_label(id!(cancel_link)).clicked(actions) {
Expand All @@ -279,7 +279,7 @@ impl WidgetMatchEvent for DownloadNotificationPopup {
&scope.path,
DownloadAction::Cancel(file_id.clone()),
);
cx.widget_action(widget_uid, &scope.path, DownloadNotificationPopupAction::ActionLinkClicked);
cx.action(DownloadNotificationPopupAction::ActionLinkClicked);
}
}
}
Expand Down

0 comments on commit 230edf5

Please sign in to comment.