Skip to content

Commit 66f426b

Browse files
committed
fixup! feat: implement logger actor
1 parent 04f3c67 commit 66f426b

17 files changed

Lines changed: 154 additions & 224 deletions

src/app.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
logger::LoggerActor,
2+
logger::Logger,
33
ui::popup::{info_popup::InfoPopUp, PopUp},
44
};
55
use ansi_to_tui::IntoText;
@@ -32,7 +32,7 @@ pub mod screens;
3232

3333
/// Type that represents the overall state of the application. It can be viewed
3434
/// as the **Model** component of `patch-hub`.
35-
pub struct App<Logger: LoggerActor> {
35+
pub struct App {
3636
/// The current active screen
3737
pub current_screen: CurrentScreen,
3838
/// Screen to navigate and select the mailing lists archived on Lore
@@ -56,7 +56,7 @@ pub struct App<Logger: LoggerActor> {
5656
pub logger: Logger,
5757
}
5858

59-
impl<Logger: LoggerActor> App<Logger> {
59+
impl App {
6060
/// Creates a new instance of `App`. It dynamically loads configurations
6161
/// based on precedence (see [crate::app::Config::build]), app data
6262
/// (available mailing lists, bookmarked patchsets, reviewed patchsets), and
@@ -65,7 +65,7 @@ impl<Logger: LoggerActor> App<Logger> {
6565
/// # Returns
6666
///
6767
/// `App` instance with loading configurations and app data.
68-
pub fn new(logger: Logger) -> App<Logger> {
68+
pub async fn new(logger: Logger) -> App {
6969
let config: Config = Config::build();
7070
config.create_dirs();
7171

@@ -84,7 +84,7 @@ impl<Logger: LoggerActor> App<Logger> {
8484

8585
// Initialize the logger before the app starts
8686
logger.info("patch-hub started");
87-
logger.collect_garbage();
87+
logger.collect_garbage().await;
8888

8989
App {
9090
current_screen: CurrentScreen::MailingListSelection,

src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clap::Parser;
44
use color_eyre::eyre::eyre;
55
use ratatui::{prelude::Backend, Terminal};
66

7-
use crate::{app::App, logger::LoggerActor, utils};
7+
use crate::{app::App, logger::Logger, utils};
88

99
#[derive(Debug, Parser)]
1010
#[command(version, about)]
@@ -21,8 +21,8 @@ impl Cli {
2121
pub fn resolve<B: Backend>(
2222
&self,
2323
terminal: Terminal<B>,
24-
app: &mut App<impl LoggerActor>,
25-
logger: impl LoggerActor,
24+
app: &mut App,
25+
logger: Logger,
2626
) -> ControlFlow<color_eyre::Result<()>, Terminal<B>> {
2727
if self.show_configs {
2828
logger.info("Printing current configurations");

src/handler.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212
use crate::{
1313
app::{screens::CurrentScreen, App},
1414
loading_screen,
15-
logger::LoggerActor,
15+
logger::Logger,
1616
ui::draw_ui,
1717
};
1818

@@ -30,7 +30,7 @@ use ratatui::{
3030

3131
fn key_handling<B>(
3232
mut terminal: Terminal<B>,
33-
app: &mut App<impl LoggerActor>,
33+
app: &mut App,
3434
key: KeyEvent,
3535
) -> color_eyre::Result<ControlFlow<(), Terminal<B>>>
3636
where
@@ -64,10 +64,7 @@ where
6464
Ok(ControlFlow::Continue(terminal))
6565
}
6666

67-
fn logic_handling<B>(
68-
mut terminal: Terminal<B>,
69-
app: &mut App<impl LoggerActor>,
70-
) -> color_eyre::Result<Terminal<B>>
67+
fn logic_handling<B>(mut terminal: Terminal<B>, app: &mut App) -> color_eyre::Result<Terminal<B>>
7168
where
7269
B: Backend + Send + 'static,
7370
{
@@ -106,11 +103,7 @@ where
106103
Ok(terminal)
107104
}
108105

109-
pub fn run_app<B>(
110-
mut terminal: Terminal<B>,
111-
mut app: App<impl LoggerActor>,
112-
logger: impl LoggerActor,
113-
) -> color_eyre::Result<()>
106+
pub fn run_app<B>(mut terminal: Terminal<B>, mut app: App, logger: Logger) -> color_eyre::Result<()>
114107
where
115108
B: Backend + Send + 'static,
116109
{

src/handler/bookmarked.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::ops::ControlFlow;
33
use crate::{
44
app::{screens::CurrentScreen, App},
55
loading_screen,
6-
logger::LoggerActor,
76
ui::popup::{help::HelpPopUpBuilder, PopUp},
87
};
98
use ratatui::{
@@ -13,7 +12,7 @@ use ratatui::{
1312
};
1413

1514
pub fn handle_bookmarked_patchsets<B>(
16-
app: &mut App<impl LoggerActor>,
15+
app: &mut App,
1716
key: KeyEvent,
1817
mut terminal: Terminal<B>,
1918
) -> color_eyre::Result<ControlFlow<(), Terminal<B>>>

src/handler/details_actions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::time::Duration;
22

33
use crate::{
44
app::{screens::CurrentScreen, App},
5-
logger::LoggerActor,
65
ui::popup::{help::HelpPopUpBuilder, review_trailers::ReviewTrailersPopUp, PopUp},
76
utils,
87
};
@@ -15,7 +14,7 @@ use ratatui::{
1514
use super::wait_key_press;
1615

1716
pub fn handle_patchset_details<B: Backend>(
18-
app: &mut App<impl LoggerActor>,
17+
app: &mut App,
1918
key: KeyEvent,
2019
terminal: &mut Terminal<B>,
2120
) -> color_eyre::Result<()> {

src/handler/edit_config.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
use crate::{
22
app::{screens::CurrentScreen, App},
3-
logger::LoggerActor,
43
ui::popup::{help::HelpPopUpBuilder, PopUp},
54
};
65
use ratatui::crossterm::event::{KeyCode, KeyEvent};
76

8-
pub fn handle_edit_config(
9-
app: &mut App<impl LoggerActor>,
10-
key: KeyEvent,
11-
) -> color_eyre::Result<()> {
7+
pub fn handle_edit_config(app: &mut App, key: KeyEvent) -> color_eyre::Result<()> {
128
if let Some(edit_config_state) = app.edit_config.as_mut() {
139
match edit_config_state.is_editing() {
1410
true => match key.code {

src/handler/latest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::ops::ControlFlow;
33
use crate::{
44
app::{screens::CurrentScreen, App},
55
loading_screen,
6-
logger::LoggerActor,
76
ui::popup::{help::HelpPopUpBuilder, PopUp},
87
};
98
use ratatui::{
@@ -13,7 +12,7 @@ use ratatui::{
1312
};
1413

1514
pub fn handle_latest_patchsets<B>(
16-
app: &mut App<impl LoggerActor>,
15+
app: &mut App,
1716
key: KeyEvent,
1817
mut terminal: Terminal<B>,
1918
) -> color_eyre::Result<ControlFlow<(), Terminal<B>>>

src/handler/mail_list.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::ops::ControlFlow;
33
use crate::{
44
app::{screens::CurrentScreen, App},
55
loading_screen,
6-
logger::LoggerActor,
76
ui::popup::{help::HelpPopUpBuilder, PopUp},
87
};
98
use ratatui::{
@@ -13,7 +12,7 @@ use ratatui::{
1312
};
1413

1514
pub fn handle_mailing_list_selection<B>(
16-
app: &mut App<impl LoggerActor>,
15+
app: &mut App,
1716
key: KeyEvent,
1817
mut terminal: Terminal<B>,
1918
) -> color_eyre::Result<ControlFlow<(), Terminal<B>>>

0 commit comments

Comments
 (0)