Skip to content

Commit

Permalink
Fix download as function to consider preview page
Browse files Browse the repository at this point in the history
  • Loading branch information
lusingander committed Sep 9, 2024
1 parent 77f52bd commit 155732e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,11 @@ impl App {
) where
F: FnOnce(Sender, Result<RawObject>, String) + Send + 'static,
{
let object_detail_page = self.page_stack.current_page().as_object_detail();
let object_key = object_detail_page.current_object_key();
let object_key = match self.page_stack.current_page() {
page @ Page::ObjectDetail(_) => page.as_object_detail().current_object_key(),
page @ Page::ObjectPreview(_) => page.as_object_preview().current_object_key(),
page => panic!("Invalid page: {:?}", page),
};

let bucket = object_key.bucket_name.clone();
let key = object_key.joined_object_path(true);
Expand Down
7 changes: 7 additions & 0 deletions src/pages/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ impl Page {
}
}

pub fn as_object_preview(&self) -> &ObjectPreviewPage {
match self {
Self::ObjectPreview(page) => page,
page => panic!("Page is not ObjectPreview: {:?}", page),
}
}

pub fn as_mut_object_preview(&mut self) -> &mut ObjectPreviewPage {
match self {
Self::ObjectPreview(page) => &mut *page,
Expand Down

0 comments on commit 155732e

Please sign in to comment.