Skip to content

Commit

Permalink
Fix blank window on first start (#81)
Browse files Browse the repository at this point in the history
- default side panel to open
- update the document widget even with the side panel collapsed
  • Loading branch information
abey79 committed Dec 27, 2023
1 parent 04293f5 commit 5cc3722
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions crates/msvg/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ enum LoadedDocument {
// TODO: Document::from_svg() should return an proper error type
}

#[derive(Default, serde::Deserialize, serde::Serialize)]
#[derive(serde::Deserialize, serde::Serialize)]
struct AppState {
side_panel_open: bool,
}

impl Default for AppState {
fn default() -> Self {
Self {
side_panel_open: true,
}
}
}

#[derive(Default)]
struct FileNameOverlay {
should_show: bool,
Expand Down Expand Up @@ -283,15 +291,6 @@ impl ViewerApp for App {
self.scroll_to_selected_row = false;
}
}

if self.document_dirty {
if let Some(LoadedDocument::Loaded(document)) =
self.loaded_documents.get(&self.paths[self.active_document])
{
document_widget.set_document(document.clone());
self.document_dirty = false;
}
}
};

// --- Side panel structure ---
Expand Down Expand Up @@ -328,6 +327,17 @@ impl ViewerApp for App {
});
});

// --- Update the document widget if needed ---

if self.document_dirty {
if let Some(LoadedDocument::Loaded(document)) =
self.loaded_documents.get(&self.paths[self.active_document])
{
document_widget.set_document(document.clone());
self.document_dirty = false;
}
}

Ok(())
}

Expand Down

0 comments on commit 5cc3722

Please sign in to comment.