fixing a lot of lints
Some checks failed
/ test (push) Failing after 5m47s

This commit is contained in:
Chris Cochrun 2026-02-15 11:17:30 -06:00
parent 3139bd3488
commit 0d7e5b9285
7 changed files with 109 additions and 116 deletions

View file

@ -25,9 +25,13 @@ pub fn save(
let save_file = File::create(path).into_diagnostic()?;
let ron = process_service_items(&list)?;
let encoder = Encoder::new(save_file, 3).unwrap().auto_finish();
let encoder = Encoder::new(save_file, 3)
.expect("file encoder shouldn't fail")
.auto_finish();
let mut tar = Builder::new(encoder);
let mut temp_dir = dirs::data_dir().unwrap();
let mut temp_dir = dirs::data_dir().expect(
"there should be a data directory, ~/.local/share/ for linux, but couldn't find it",
);
temp_dir.push("lumina");
let mut s: String =
iter::repeat_with(fastrand::alphanumeric).take(5).collect();
@ -40,7 +44,6 @@ pub fn save(
match fs::File::options()
.read(true)
.write(true)
.create(true)
.open(service_file)
{
Ok(mut f) => {
@ -135,10 +138,7 @@ pub fn save(
fn process_service_items(items: &Vec<ServiceItem>) -> Result<String> {
Ok(items
.iter()
.filter_map(|item| {
let ron = ron::ser::to_string(item);
ron.ok()
})
.filter_map(|item| ron::ser::to_string(item).ok())
.collect())
}

View file

@ -368,6 +368,7 @@ impl From<&Presentation> for ServiceItem {
}
}
#[allow(unused)]
impl Service {
fn add_item(
&mut self,

View file

@ -1,3 +1,4 @@
#![allow(clippy::similar_names, unused)]
use cosmic::widget::image::Handle;
// use cosmic::dialog::ashpd::url::Url;
use crisp::types::{Keyword, Symbol, Value};
@ -48,13 +49,6 @@ pub enum BackgroundKind {
Html,
}
#[derive(Debug, Clone, Default)]
struct Image {
pub source: String,
pub fit: String,
pub children: Vec<String>,
}
#[derive(
Clone,
Copy,
@ -391,10 +385,6 @@ impl Slide {
self.id = index;
}
pub(crate) fn text_to_image(&self) {
todo!()
}
// pub fn slides_from_item(item: &ServiceItem) -> Result<Vec<Self>> {
// todo!()
// }
@ -750,12 +740,6 @@ impl SlideBuilder {
}
}
impl Image {
fn new() -> Self {
Default::default()
}
}
#[cfg(test)]
mod test {
use pretty_assertions::assert_eq;

View file

@ -781,7 +781,7 @@ pub async fn get_song_from_db(
index: i32,
db: &mut SqliteConnection,
) -> Result<Song> {
let row = query(r#"SELECT verse_order, font_size, background_type, horizontal_text_alignment, vertical_text_alignment, title, font, background, lyrics, ccli, author, audio, stroke_size, stroke_color, shadow_color, shadow_size, shadow_offset_x, shadow_offset_y, id from songs where id = $1"#).bind(index).fetch_one(db).await.into_diagnostic()?;
let row = query("SELECT verse_order, font_size, background_type, horizontal_text_alignment, vertical_text_alignment, title, font, background, lyrics, ccli, author, audio, stroke_size, stroke_color, shadow_color, shadow_size, shadow_offset_x, shadow_offset_y, id from songs where id = $1").bind(index).fetch_one(db).await.into_diagnostic()?;
Song::from_row(&row).into_diagnostic()
}
@ -799,7 +799,7 @@ impl Model<Song> {
pub async fn load_from_db(&mut self, db: &mut SqlitePool) {
// static DATABASE_URL: &str = "sqlite:///home/chris/.local/share/lumina/library-db.sqlite3";
let db1 = db.acquire().await.unwrap();
let result = query(r"SELECT verse_order, font_size, background_type, horizontal_text_alignment, vertical_text_alignment, title, font, background, lyrics, ccli, author, audio, stroke_size, shadow_size, stroke_color, shadow_color, shadow_offset_x, shadow_offset_y, id from songs").fetch_all(&mut db1.detach()).await;
let result = query("SELECT verse_order, font_size, background_type, horizontal_text_alignment, vertical_text_alignment, title, font, background, lyrics, ccli, author, audio, stroke_size, shadow_size, stroke_color, shadow_color, shadow_offset_x, shadow_offset_y, id from songs").fetch_all(&mut db1.detach()).await;
match result {
Ok(s) => {
for song in s {
@ -1034,67 +1034,67 @@ impl Song {
// old implementation
// ---------------------------------
let mut lyric_list = Vec::new();
if self.lyrics.is_none() {
return Err(miette!("There is no lyrics here"));
} else if self.verse_order.is_none() {
return Err(miette!("There is no verse_order here"));
} else if self
.verse_order
.clone()
.is_some_and(|v| v.is_empty())
{
return Err(miette!("There is no verse_order here"));
}
if let Some(raw_lyrics) = self.lyrics.clone() {
let raw_lyrics = raw_lyrics.as_str();
let verse_order = self.verses.clone();
// let mut lyric_list = Vec::new();
// if self.lyrics.is_none() {
// return Err(miette!("There is no lyrics here"));
// } else if self.verse_order.is_none() {
// return Err(miette!("There is no verse_order here"));
// } else if self
// .verse_order
// .clone()
// .is_some_and(|v| v.is_empty())
// {
// return Err(miette!("There is no verse_order here"));
// }
// if let Some(raw_lyrics) = self.lyrics.clone() {
// let raw_lyrics = raw_lyrics.as_str();
// let verse_order = self.verses.clone();
let mut lyric_map = HashMap::new();
let mut verse_title = String::new();
let mut lyric = String::new();
for (i, line) in raw_lyrics.split('\n').enumerate() {
if VERSE_KEYWORDS.contains(&line) {
if i != 0 {
lyric_map.insert(verse_title, lyric);
lyric = String::new();
verse_title = line.to_string();
} else {
verse_title = line.to_string();
}
} else {
lyric.push_str(line);
lyric.push('\n');
}
}
lyric_map.insert(verse_title, lyric);
// let mut lyric_map = HashMap::new();
// let mut verse_title = String::new();
// let mut lyric = String::new();
// for (i, line) in raw_lyrics.split('\n').enumerate() {
// if VERSE_KEYWORDS.contains(&line) {
// if i != 0 {
// lyric_map.insert(verse_title, lyric);
// lyric = String::new();
// verse_title = line.to_string();
// } else {
// verse_title = line.to_string();
// }
// } else {
// lyric.push_str(line);
// lyric.push('\n');
// }
// }
// lyric_map.insert(verse_title, lyric);
for verse in verse_order.unwrap_or_default() {
let verse_name = &verse.get_name();
if let Some(lyric) = lyric_map.get(verse_name) {
if lyric.contains("\n\n") {
let split_lyrics: Vec<&str> =
lyric.split("\n\n").collect();
for lyric in split_lyrics {
if lyric.is_empty() {
continue;
}
lyric_list.push(lyric.to_string());
}
continue;
}
lyric_list.push(lyric.clone());
} else {
// error!("NOT WORKING!");
}
}
// for lyric in lyric_list.iter() {
// debug!(lyric = ?lyric)
// }
Ok(lyric_list)
} else {
Err(miette!("There are no lyrics"))
}
// for verse in verse_order.unwrap_or_default() {
// let verse_name = &verse.get_name();
// if let Some(lyric) = lyric_map.get(verse_name) {
// if lyric.contains("\n\n") {
// let split_lyrics: Vec<&str> =
// lyric.split("\n\n").collect();
// for lyric in split_lyrics {
// if lyric.is_empty() {
// continue;
// }
// lyric_list.push(lyric.to_string());
// }
// continue;
// }
// lyric_list.push(lyric.clone());
// } else {
// // error!("NOT WORKING!");
// }
// }
// // for lyric in lyric_list.iter() {
// // debug!(lyric = ?lyric)
// // }
// Ok(lyric_list)
// } else {
// Err(miette!("There are no lyrics"))
// }
}
pub fn update_verse_name(

View file

@ -1,3 +1,4 @@
#![allow(clippy::option_if_let_else)]
use clap::Parser;
use core::service_items::ServiceItem;
use core::slide::{
@ -436,7 +437,7 @@ impl cosmic::Application for App {
batch.push(app.show_window());
}
batch.push(app.add_library());
batch.push(add_library());
// batch.push(app.add_service(items, Arc::clone(&fontdb)));
let batch = Task::batch(batch);
(app, batch)
@ -1671,7 +1672,7 @@ impl cosmic::Application for App {
if let Some(library) = &self.library {
library.view().map(Message::Library)
} else {
Space::new(0, 0).into()
Element::from(Space::new(0, 0))
},
)
.style(nav_bar_style),
@ -1814,14 +1815,8 @@ where
.map(|id| cosmic::Action::App(Message::WindowOpened(id)))
}
fn add_library(&self) -> Task<Message> {
Task::perform(async move { Library::new().await }, |x| {
cosmic::Action::App(Message::AddLibrary(x))
})
}
fn search(&self, query: String) -> Task<Message> {
if let Some(library) = self.library.clone() {
self.library.clone().map_or_else(Task::none, |library| {
Task::perform(
async move { library.search_items(query).await },
|items| {
@ -1830,9 +1825,19 @@ where
))
},
)
} else {
Task::none()
}
})
// if let Some(library) = self.library.clone() {
// Task::perform(
// async move { library.search_items(query).await },
// |items| {
// cosmic::Action::App(Message::UpdateSearchResults(
// items,
// ))
// },
// )
// } else {
// Task::none()
// }
}
fn process_key_press(
@ -1906,6 +1911,7 @@ where
}
}
#[allow(clippy::too_many_lines)]
fn service_list(&self) -> Element<Message> {
let list =
self.service.iter().enumerate().map(|(index, item)| {
@ -2178,6 +2184,12 @@ where
}
}
fn add_library() -> Task<Message> {
Task::perform(async move { Library::new().await }, |x| {
cosmic::Action::App(Message::AddLibrary(x))
})
}
async fn save_as_dialog() -> Result<PathBuf> {
let dialog = save::Dialog::new();

View file

@ -1,3 +1,4 @@
#![allow(clippy::similar_names)]
use std::{
fmt::Display,
io::{self},
@ -14,7 +15,6 @@ use cosmic::{
alignment::Vertical,
color,
font::{Style, Weight},
futures::StreamExt,
task,
},
iced_core::widget::tree,
@ -153,7 +153,7 @@ pub enum Message {
}
#[derive(Debug, Clone)]
struct Face(fontdb::FaceInfo);
pub struct Face(fontdb::FaceInfo);
impl Display for Face {
fn fmt(
@ -1841,6 +1841,7 @@ impl SongEditor {
}
}
#[allow(clippy::unreadable_literal)]
fn verse_chip(
verse: VerseName,
index: Option<usize>,
@ -1854,7 +1855,7 @@ fn verse_chip(
} = theme::spacing();
const VERSE_COLOR: cosmic::iced::Color = color!(0xf26430);
const CHORUS_COLOR: cosmic::iced::Color = color!(0x3A86ff);
const CHORUS_COLOR: cosmic::iced::Color = color!(0x3a86ff);
const BRIDGE_COLOR: cosmic::iced::Color = color!(0x47e5bc);
const INSTRUMENTAL_COLOR: cosmic::iced::Color = color!(0xd90368);
const OTHER_COLOR: cosmic::iced::Color = color!(0xffd400);

View file

@ -408,22 +408,17 @@ impl TextSvg {
}
final_svg.push('>');
let text: String = self
.text
.lines()
.enumerate()
.map(|(index, text)| {
format!(
"<tspan x=\"0\" y=\"{}\">{}</tspan>",
(index as f32).mul_add(
text_and_line_spacing,
starting_y_position
),
text
)
})
.collect();
final_svg.push_str(&text);
for (index, text) in self.text.lines().enumerate() {
let tspan = format!(
"<tspan x=\"0\" y=\"{}\">{}</tspan>",
(index as f32).mul_add(
text_and_line_spacing,
starting_y_position
),
text
);
final_svg.push_str(&tspan);
}
final_svg.push_str("</text></svg>");