Revert "introduce decks_cache"

This was causing a crash when switching accounts

This reverts commit 69e93b0ebf.
This commit is contained in:
William Casarin
2024-12-09 09:03:34 -08:00
parent 1b31557b03
commit 32caaee642
7 changed files with 82 additions and 176 deletions

View File

@@ -2,6 +2,7 @@ use crate::colors::PINK;
use crate::imgcache::ImageCache;
use crate::{
accounts::Accounts,
route::{Route, Router},
ui::{Preview, PreviewConfig, View},
Damus,
};
@@ -202,12 +203,15 @@ mod preview {
pub struct AccountsPreview {
app: Damus,
router: Router<Route>,
}
impl AccountsPreview {
fn new() -> Self {
let app = test_data::test_app();
AccountsPreview { app }
let router = Router::new(vec![Route::accounts()]);
AccountsPreview { app, router }
}
}
@@ -220,12 +224,7 @@ mod preview {
.ui(ui)
.inner
{
process_accounts_view_response(
&mut self.app.accounts,
&mut self.app.decks_cache,
0,
response,
);
process_accounts_view_response(self.app.accounts_mut(), response, &mut self.router);
}
}
}

View File

@@ -4,11 +4,9 @@ use egui::{
use tracing::info;
use crate::{
accounts::{Accounts, AccountsRoute},
app::get_active_columns_mut,
accounts::AccountsRoute,
app_style, colors,
column::Column,
decks::DecksCache,
column::{Column, Columns},
imgcache::ImageCache,
route::Route,
support::Support,
@@ -29,7 +27,6 @@ pub struct DesktopSidePanel<'a> {
ndb: &'a nostrdb::Ndb,
img_cache: &'a mut ImageCache,
selected_account: Option<&'a UserAccount>,
decks_cache: &'a DecksCache,
}
impl View for DesktopSidePanel<'_> {
@@ -66,13 +63,11 @@ impl<'a> DesktopSidePanel<'a> {
ndb: &'a nostrdb::Ndb,
img_cache: &'a mut ImageCache,
selected_account: Option<&'a UserAccount>,
decks_cache: &'a DecksCache,
) -> Self {
Self {
ndb,
img_cache,
selected_account,
decks_cache,
}
}
@@ -205,13 +200,8 @@ impl<'a> DesktopSidePanel<'a> {
helper.take_animation_response()
}
pub fn perform_action(
decks_cache: &mut DecksCache,
accounts: &Accounts,
support: &mut Support,
action: SidePanelAction,
) {
let router = get_active_columns_mut(accounts, decks_cache).get_first_router();
pub fn perform_action(columns: &mut Columns, support: &mut Support, action: SidePanelAction) {
let router = columns.get_first_router();
match action {
SidePanelAction::Panel => {} // TODO
SidePanelAction::Account => {
@@ -242,7 +232,7 @@ impl<'a> DesktopSidePanel<'a> {
{
router.go_back();
} else {
get_active_columns_mut(accounts, decks_cache).new_column_picker();
columns.new_column_picker();
}
}
SidePanelAction::ComposeNote => {
@@ -480,7 +470,6 @@ mod preview {
use egui_extras::{Size, StripBuilder};
use crate::{
app::get_active_columns_mut,
test_data,
ui::{Preview, PreviewConfig},
};
@@ -494,8 +483,7 @@ mod preview {
impl DesktopSidePanelPreview {
fn new() -> Self {
let mut app = test_data::test_app();
get_active_columns_mut(&app.accounts, &mut app.decks_cache)
.add_column(Column::new(vec![Route::accounts()]));
app.columns.add_column(Column::new(vec![Route::accounts()]));
DesktopSidePanelPreview { app }
}
}
@@ -512,13 +500,11 @@ mod preview {
&self.app.ndb,
&mut self.app.img_cache,
self.app.accounts.get_selected_account(),
&self.app.decks_cache,
);
let response = panel.show(ui);
DesktopSidePanel::perform_action(
&mut self.app.decks_cache,
&self.app.accounts,
&mut self.app.columns,
&mut self.app.support,
response.action,
);