diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs index da15b7be..e506c3b8 100644 --- a/crates/notedeck_columns/src/ui/note/post.rs +++ b/crates/notedeck_columns/src/ui/note/post.rs @@ -367,46 +367,7 @@ impl<'a, 'd> PostView<'a, 'd> { self.transfer_uploads(ui); self.show_upload_errors(ui); - let post_action = ui - .horizontal(|ui| { - ui.with_layout( - egui::Layout::left_to_right(egui::Align::BOTTOM), - |ui| { - self.show_upload_media_button(ui); - }, - ); - - ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| { - let post_button_clicked = ui - .add_sized( - [91.0, 32.0], - post_button(!self.draft.buffer.is_empty()), - ) - .clicked(); - - let shortcut_pressed = ui.input(|i| { - (i.modifiers.ctrl || i.modifiers.command) - && i.key_pressed(egui::Key::Enter) - }); - - if post_button_clicked - || (!self.draft.buffer.is_empty() && shortcut_pressed) - { - let output = self.draft.buffer.output(); - let new_post = NewPost::new( - output.text, - self.poster.to_full(), - self.draft.uploaded_media.clone(), - output.mentions, - ); - Some(NewPostAction::new(self.post_type.clone(), new_post)) - } else { - None - } - }) - .inner - }) - .inner; + let post_action = ui.horizontal(|ui| self.input_buttons(ui)).inner; let action = note_response .and_then(|nr| nr.action.map(PostAction::QuotedNoteAction)) @@ -422,6 +383,36 @@ impl<'a, 'd> PostView<'a, 'd> { .inner } + fn input_buttons(&mut self, ui: &mut egui::Ui) -> Option { + ui.with_layout(egui::Layout::left_to_right(egui::Align::BOTTOM), |ui| { + self.show_upload_media_button(ui); + }); + + ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| { + let post_button_clicked = ui + .add_sized([91.0, 32.0], post_button(!self.draft.buffer.is_empty())) + .clicked(); + + let shortcut_pressed = ui.input(|i| { + (i.modifiers.ctrl || i.modifiers.command) && i.key_pressed(egui::Key::Enter) + }); + + if post_button_clicked || (!self.draft.buffer.is_empty() && shortcut_pressed) { + let output = self.draft.buffer.output(); + let new_post = NewPost::new( + output.text, + self.poster.to_full(), + self.draft.uploaded_media.clone(), + output.mentions, + ); + Some(NewPostAction::new(self.post_type.clone(), new_post)) + } else { + None + } + }) + .inner + } + fn show_media(&mut self, ui: &mut egui::Ui) { let mut to_remove = Vec::new(); for (i, media) in self.draft.uploaded_media.iter().enumerate() {