Moving to Rust 1.87 introduced a clippy warning that `SendError<AppEvent>` was too large. In practice, the only thing we ever did when we got this error was log it (if the mspc channel is closed, then the app is likely shutting down or something, so there's not much to do...), so this finally motivated me to introduce `AppEventSender`, which wraps `std::sync::mpsc::Sender<AppEvent>` with a `send()` method that invokes `send()` on the underlying `Sender` and logs an `Err` if it gets one. This greatly simplifies the code, as many functions that previously returned `Result<(), SendError<AppEvent>>` now return `()`, so we don't have to propagate an `Err` all over the place that we don't really handle, anyway. This also makes it so we can upgrade to Rust 1.87 in CI.
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
use ratatui::buffer::Buffer;
|
|
use ratatui::layout::Rect;
|
|
use ratatui::widgets::WidgetRef;
|
|
|
|
use crate::app_event_sender::AppEventSender;
|
|
use crate::status_indicator_widget::StatusIndicatorWidget;
|
|
|
|
use super::BottomPaneView;
|
|
use super::bottom_pane_view::ConditionalUpdate;
|
|
|
|
pub(crate) struct StatusIndicatorView {
|
|
view: StatusIndicatorWidget,
|
|
}
|
|
|
|
impl StatusIndicatorView {
|
|
pub fn new(app_event_tx: AppEventSender, height: u16) -> Self {
|
|
Self {
|
|
view: StatusIndicatorWidget::new(app_event_tx, height),
|
|
}
|
|
}
|
|
|
|
pub fn update_text(&mut self, text: String) {
|
|
self.view.update_text(text);
|
|
}
|
|
}
|
|
|
|
impl<'a> BottomPaneView<'a> for StatusIndicatorView {
|
|
fn update_status_text(&mut self, text: String) -> ConditionalUpdate {
|
|
self.update_text(text);
|
|
ConditionalUpdate::NeedsRedraw
|
|
}
|
|
|
|
fn should_hide_when_task_is_done(&mut self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn calculate_required_height(&self, _area: &Rect) -> u16 {
|
|
self.view.get_height()
|
|
}
|
|
|
|
fn render(&self, area: Rect, buf: &mut Buffer) {
|
|
self.view.render_ref(area, buf);
|
|
}
|
|
}
|