Skip to content

Commit

Permalink
fix edit deck bug
Browse files Browse the repository at this point in the history
Signed-off-by: kernelkind <[email protected]>
  • Loading branch information
kernelkind committed Dec 11, 2024
1 parent c08b5a6 commit 06c9023
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus) {
);
});

let mut save_cols = false;
if let Some(action) = side_panel_action {
save_cols = save_cols || action.process(app);
}

let num_cols = app.columns().num_columns();
let mut responses = Vec::with_capacity(num_cols);
for col_index in 0..num_cols {
Expand All @@ -747,11 +752,6 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus) {
//strip.cell(|ui| timeline::timeline_view(ui, app, timeline_ind));
}

let mut save_cols = false;
if let Some(action) = side_panel_action {
save_cols = save_cols || action.process(app);
}

for response in responses {
let save = response.process_render_nav_response(app);
save_cols = save_cols || save;
Expand Down
2 changes: 0 additions & 2 deletions src/deck_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{app_style::emoji_font_family, decks::Deck};
pub struct DeckState {
pub deck_name: String,
pub selected_glyph: Option<char>,
pub deleting: bool,
pub selecting_glyph: bool,
pub warn_no_title: bool,
pub warn_no_icon: bool,
Expand Down Expand Up @@ -42,7 +41,6 @@ impl Default for DeckState {
Self {
deck_name: Default::default(),
selected_glyph: Default::default(),
deleting: Default::default(),
selecting_glyph: true,
warn_no_icon: Default::default(),
warn_no_title: Default::default(),
Expand Down
11 changes: 5 additions & 6 deletions src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ impl RenderNavResponse {
);
}

if let Some(Route::EditDeck(index)) = r {
SwitchingAction::Decks(DecksAction::Removing(index)).process(app);
}

switching_occured = true;
}

Expand Down Expand Up @@ -318,6 +314,7 @@ fn render_nav_body(
resp
}
Route::EditDeck(index) => {
let mut action = None;
let cur_deck = get_decks_mut(&app.accounts, &mut app.decks_cache)
.decks_mut()
.get_mut(*index)
Expand All @@ -338,15 +335,17 @@ fn render_nav_body(
cur_deck.edit(configure_deck_response);
}
EditDeckResponse::Delete => {
deck_state.deleting = true;
action = Some(RenderNavAction::SwitchingAction(SwitchingAction::Decks(
DecksAction::Removing(*index),
)));
}
}
get_active_columns_mut(&app.accounts, &mut app.decks_cache)
.get_first_router()
.go_back();
}

None
action
}
}
}
Expand Down
25 changes: 18 additions & 7 deletions src/ui/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ use egui::{
vec2, Color32, InnerResponse, Label, Layout, Margin, RichText, ScrollArea, Separator, Stroke,
Widget,
};
use tracing::info;
use tracing::{error, info};

use crate::{
accounts::{Accounts, AccountsRoute},
app::get_active_columns_mut,
app_style,
app_style::DECK_ICON_SIZE,
app::{get_active_columns_mut, get_decks_mut},
app_style::{self, DECK_ICON_SIZE},
colors,
column::Column,
decks::DecksAction,
decks::DecksCache,
decks::{DecksAction, DecksCache},
imgcache::ImageCache,
nav::SwitchingAction,
route::Route,
Expand Down Expand Up @@ -331,7 +329,20 @@ impl<'a> DesktopSidePanel<'a> {
if router.routes().iter().any(|&r| r == Route::EditDeck(index)) {
router.go_back();
} else {
router.route_to(Route::EditDeck(index));
switching_response = Some(crate::nav::SwitchingAction::Decks(
DecksAction::Switch(index),
));
if let Some(edit_deck) = get_decks_mut(accounts, decks_cache)
.decks_mut()
.get_mut(index)
{
edit_deck
.columns_mut()
.get_first_router()
.route_to(Route::EditDeck(index));
} else {
error!("Cannot push EditDeck route to index {}", index);
}
}
}
}
Expand Down

0 comments on commit 06c9023

Please sign in to comment.