diff --git a/src/app.rs b/src/app.rs index 9679b37..5e3dff3 100644 --- a/src/app.rs +++ b/src/app.rs @@ -533,8 +533,11 @@ impl App { ) where F: FnOnce(Sender, Result, 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); diff --git a/src/pages/page.rs b/src/pages/page.rs index faa73e7..3dbc3ac 100644 --- a/src/pages/page.rs +++ b/src/pages/page.rs @@ -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,