Removes the TUI in favor of event based logging #15

Merged
Neshura merged 17 commits from remove_tui into main 2023-12-30 00:28:47 +00:00
Showing only changes of commit 89b2d19c80 - Show all commits

View file

@ -4,7 +4,7 @@ use std::ops::Sub;
use chrono::{DateTime, Duration, Utc};
use serde_derive::{Deserialize, Serialize};
use url::Url;
use crate::{HTTP_CLIENT};
use crate::{HTTP_CLIENT, write_error};
use crate::jnovel::PartInfo::{NoParts, Part};
use crate::jnovel::PostInfo::{Chapter, Volume};
@ -222,7 +222,7 @@ impl PartialOrd for PostInfo {
}
}
pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Result<Vec<PostInfo>, String> {
pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Result<Vec<PostInfo>, ()> {
let response = match HTTP_CLIENT
.get(api_url!() + "/series/" + series_slug + "/volumes?format=json")
.send()
@ -230,15 +230,27 @@ pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Res
Ok(data) => {
match data.text().await {
Ok(data) => data,
Err(e) => return Err(format!("{}", e))
Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
}
}
},
Err(e) => return Err(format!("{}", e))
Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
}
};
let mut volume_brief_data: VolumesWrapper = match serde_json::from_str(&response) {
Ok(data) => data,
Err(e) => return Err(format!("{}", e))
Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
}
};
volume_brief_data.volumes.reverse(); // Makes breaking out of the volume loop easier
@ -330,7 +342,7 @@ pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Res
Ok(result_vec)
}
async fn get_latest_prepub(volume_slug: &str) -> Result<Option<LemmyPostInfo>, String> {
async fn get_latest_prepub(volume_slug: &str) -> Result<Option<LemmyPostInfo>, ()> {
let response = match HTTP_CLIENT
.get(api_url!() + "/volumes/" + volume_slug + "/parts?format=json")
.send()
@ -338,16 +350,28 @@ async fn get_latest_prepub(volume_slug: &str) -> Result<Option<LemmyPostInfo>, S
Ok(data) => {
match data.text().await {
Ok(data) => data,
Err(e) => return Err(e.to_string())
Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
}
}
},
Err(e) => return Err(format!("{}", e))
Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
}
};
let mut volume_prepub_parts_data: ChapterWrapper = match serde_json::from_str(&response) {
Ok(data) => data,
Err(e) => return Err(format!("{}", e))
Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
}
};
volume_prepub_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier