fixing lints
This commit is contained in:
parent
ab01a4bba8
commit
01993ea7eb
10 changed files with 84 additions and 387 deletions
|
|
@ -15,7 +15,7 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize,
|
||||
|
|
@ -157,69 +157,6 @@ impl ServiceTrait for Image {
|
|||
}
|
||||
|
||||
impl Model<Image> {
|
||||
pub async fn append_image(
|
||||
&mut self,
|
||||
image: Image,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn new_image(
|
||||
&mut self,
|
||||
db: &SqlitePool,
|
||||
) -> Result<Image> {
|
||||
todo!()
|
||||
}
|
||||
pub async fn update_image(
|
||||
&mut self,
|
||||
image: Image,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
let id = image.id;
|
||||
self.update_item(image.clone(), |current_image| {
|
||||
current_image.id == id
|
||||
})?;
|
||||
let path = image
|
||||
.path
|
||||
.to_str()
|
||||
.map(std::string::ToString::to_string)
|
||||
.unwrap_or_default();
|
||||
debug!(?image, "should be been updated");
|
||||
let result = query!(
|
||||
r#"UPDATE images SET title = $2, file_path = $3 WHERE id = $1"#,
|
||||
image.id,
|
||||
image.title,
|
||||
path,
|
||||
)
|
||||
.execute(db)
|
||||
.await.into_diagnostic();
|
||||
|
||||
match result {
|
||||
Ok(_) => {
|
||||
debug!("should have been updated");
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error! {?e};
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn remove_image(
|
||||
&mut self,
|
||||
id: i32,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
self.remove_item(|image| image.id == id)?;
|
||||
query!("DELETE FROM images WHERE id = $1", id)
|
||||
.execute(db)
|
||||
.await
|
||||
.into_diagnostic()
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
pub async fn new_image_model(db: &mut SqlitePool) -> Self {
|
||||
let mut model = Self {
|
||||
items: vec![],
|
||||
|
|
@ -328,7 +265,7 @@ pub async fn update_image(
|
|||
.expect("We should have this image already")
|
||||
})?;
|
||||
|
||||
replace(current_image, image);
|
||||
let _ = replace(current_image, image);
|
||||
Ok(images)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ impl<T> Model<T> {
|
|||
self.items
|
||||
.iter()
|
||||
.position(predicate)
|
||||
.ok_or(miette!("Item cannot be found"))
|
||||
.ok_or_else(|| miette!("Item cannot be found"))
|
||||
.map(|index| self.items.get_mut(index).expect("Since we found position this should always exist"))
|
||||
.map(|current_item| {
|
||||
let _old_item = replace(current_item, item);
|
||||
|
|
@ -108,7 +108,7 @@ impl<T> Model<T> {
|
|||
self.items
|
||||
.iter()
|
||||
.position(predicate)
|
||||
.ok_or(miette!("Item cannot be found"))
|
||||
.ok_or_else(|| miette!("Item cannot be found"))
|
||||
.map(|index| {
|
||||
self.items.remove(index);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use miette::{IntoDiagnostic, Result, miette};
|
|||
use mupdf::{Colorspace, Document, Matrix};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
Row, Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection,
|
||||
prelude::FromRow, query, sqlite::SqliteRow,
|
||||
Row, SqliteConnection, SqlitePool, prelude::FromRow, query,
|
||||
sqlite::SqliteRow,
|
||||
};
|
||||
use std::{
|
||||
mem::replace,
|
||||
|
|
@ -302,35 +302,6 @@ impl FromRow<'_, SqliteRow> for Presentation {
|
|||
}
|
||||
|
||||
impl Model<Presentation> {
|
||||
pub async fn append_presentation(
|
||||
&mut self,
|
||||
presentation: Presentation,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn new_presentation(
|
||||
&mut self,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn update_presentation(
|
||||
&mut self,
|
||||
presentation: Presentation,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
pub async fn remove_presentation(
|
||||
&mut self,
|
||||
id: i32,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
pub async fn new_presentation_model(db: &mut SqlitePool) -> Self {
|
||||
let mut model = Self {
|
||||
items: vec![],
|
||||
|
|
@ -519,7 +490,7 @@ pub async fn update_presentation(
|
|||
.expect("We should have this presentation already")
|
||||
})?;
|
||||
|
||||
replace(current_presentation, presentation);
|
||||
let _ = replace(current_presentation, presentation);
|
||||
Ok(presentations)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use itertools::Itertools;
|
|||
use miette::{IntoDiagnostic, Result, miette};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
FromRow, Row, Sqlite, SqliteConnection, SqlitePool,
|
||||
pool::PoolConnection, query, sqlite::SqliteRow,
|
||||
FromRow, Row, SqliteConnection, SqlitePool, query,
|
||||
sqlite::SqliteRow,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
|
||||
|
|
@ -509,8 +509,10 @@ impl FromRow<'_, SqliteRow> for Song {
|
|||
|
||||
impl From<OnlineSong> for Song {
|
||||
fn from(value: OnlineSong) -> Self {
|
||||
let mut song = Self::default();
|
||||
song.verse_map = Some(HashMap::new());
|
||||
let mut song = Self {
|
||||
verse_map: Some(HashMap::new()),
|
||||
..Default::default()
|
||||
};
|
||||
for line in value.lyrics.lines() {
|
||||
let next_verse = song.get_next_verse_name();
|
||||
if let Some(verse_map) = song.verse_map.as_mut() {
|
||||
|
|
@ -740,187 +742,6 @@ pub async fn get_song_from_db(
|
|||
}
|
||||
|
||||
impl Model<Song> {
|
||||
// Not sure we will use this function. As it is, it makes more sense for
|
||||
// a new song to be made within the model and then passed back out.
|
||||
// But maybe for encapsulation reasons, it makes sense to have this?
|
||||
pub async fn append_song(
|
||||
&mut self,
|
||||
song: Song,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
self.add_item(song)?;
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn new_song(
|
||||
&mut self,
|
||||
db: Arc<SqlitePool>,
|
||||
) -> Result<Song> {
|
||||
let mut song = Song::default();
|
||||
|
||||
let verse_order = {
|
||||
song.verse_order.clone().map_or_else(String::new, |vo| {
|
||||
vo.into_iter()
|
||||
.map(|mut s| {
|
||||
s.push(' ');
|
||||
s
|
||||
})
|
||||
.collect::<String>()
|
||||
})
|
||||
};
|
||||
|
||||
let audio = song
|
||||
.audio
|
||||
.clone()
|
||||
.map(|a| a.to_str().unwrap_or_default().to_string());
|
||||
|
||||
let background = song
|
||||
.background
|
||||
.clone()
|
||||
.map(|b| b.path.to_str().unwrap_or_default().to_string());
|
||||
|
||||
let res = query!(
|
||||
r#"INSERT INTO songs (title, lyrics, author, ccli, verse_order, audio, font, font_size, background) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)"#,
|
||||
song.title,
|
||||
song.lyrics,
|
||||
song.author,
|
||||
song.ccli,
|
||||
verse_order,
|
||||
audio,
|
||||
song.font,
|
||||
song.font_size,
|
||||
background
|
||||
)
|
||||
.execute(&*db)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
song.id = i32::try_from(res.last_insert_rowid()).expect(
|
||||
"Fairly confident that this number won't get that high",
|
||||
);
|
||||
self.add_item(song.clone())?;
|
||||
Ok(song)
|
||||
}
|
||||
|
||||
pub async fn update_song(
|
||||
&mut self,
|
||||
song: Song,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
let id = song.id;
|
||||
self.update_item(song.clone(), |song| song.id == id)?;
|
||||
// debug!(?item);
|
||||
let verse_order =
|
||||
ron::ser::to_string(&song.verses).into_diagnostic()?;
|
||||
|
||||
let audio = song
|
||||
.audio
|
||||
.map(|a| a.to_str().unwrap_or_default().to_string());
|
||||
|
||||
let background = song
|
||||
.background
|
||||
.map(|b| b.path.to_str().unwrap_or_default().to_string());
|
||||
|
||||
let lyrics = song.verse_map.map(|map| {
|
||||
map.iter()
|
||||
.map(|(name, lyric)| {
|
||||
let lyric =
|
||||
lyric.trim_end_matches('\n').to_string();
|
||||
(name.to_owned(), lyric)
|
||||
})
|
||||
.collect::<HashMap<VerseName, String>>()
|
||||
});
|
||||
let lyrics =
|
||||
ron::ser::to_string(&lyrics).into_diagnostic()?;
|
||||
|
||||
let (vertical_alignment, horizontal_alignment) =
|
||||
song.text_alignment.map_or_else(
|
||||
|| ("center", "center"),
|
||||
|ta| match ta {
|
||||
TextAlignment::TopLeft => ("top", "left"),
|
||||
TextAlignment::TopCenter => ("top", "center"),
|
||||
TextAlignment::TopRight => ("top", "right"),
|
||||
TextAlignment::MiddleLeft => ("center", "left"),
|
||||
TextAlignment::MiddleCenter => {
|
||||
("center", "center")
|
||||
}
|
||||
TextAlignment::MiddleRight => ("center", "right"),
|
||||
TextAlignment::BottomLeft => ("bottom", "left"),
|
||||
TextAlignment::BottomCenter => {
|
||||
("bottom", "center")
|
||||
}
|
||||
TextAlignment::BottomRight => ("bottom", "right"),
|
||||
},
|
||||
);
|
||||
|
||||
let stroke_size = song.stroke_size.unwrap_or_default();
|
||||
let shadow_size = song.shadow_size.unwrap_or_default();
|
||||
let (shadow_offset_x, shadow_offset_y) =
|
||||
song.shadow_offset.unwrap_or_default();
|
||||
|
||||
let stroke_color = ron::ser::to_string(&song.stroke_color)
|
||||
.into_diagnostic()?;
|
||||
let shadow_color = ron::ser::to_string(&song.shadow_color)
|
||||
.into_diagnostic()?;
|
||||
|
||||
let style = ron::ser::to_string(&song.font_style)
|
||||
.into_diagnostic()?;
|
||||
let weight = ron::ser::to_string(&song.font_weight)
|
||||
.into_diagnostic()?;
|
||||
|
||||
// debug!(
|
||||
// ?stroke_size,
|
||||
// ?stroke_color,
|
||||
// ?shadow_size,
|
||||
// ?shadow_color,
|
||||
// ?shadow_offset_x,
|
||||
// ?shadow_offset_y
|
||||
// );
|
||||
|
||||
let result = query!(
|
||||
r#"UPDATE songs SET title = $2, lyrics = $3, author = $4, ccli = $5, verse_order = $6, audio = $7, font = $8, font_size = $9, background = $10, horizontal_text_alignment = $11, vertical_text_alignment = $12, stroke_color = $13, shadow_color = $14, stroke_size = $15, shadow_size = $16, shadow_offset_x = $17, shadow_offset_y = $18, style = $19, weight = $20 WHERE id = $1"#,
|
||||
song.id,
|
||||
song.title,
|
||||
lyrics,
|
||||
song.author,
|
||||
song.ccli,
|
||||
verse_order,
|
||||
audio,
|
||||
song.font,
|
||||
song.font_size,
|
||||
background,
|
||||
horizontal_alignment,
|
||||
vertical_alignment,
|
||||
stroke_color,
|
||||
shadow_color,
|
||||
stroke_size,
|
||||
shadow_size,
|
||||
shadow_offset_x,
|
||||
shadow_offset_y,
|
||||
style,
|
||||
weight
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
|
||||
debug!(rows_affected = ?result.rows_affected());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn remove_song(
|
||||
&mut self,
|
||||
id: i32,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
self.remove_item(|current_song| id == current_song.id)?;
|
||||
query!("DELETE FROM songs WHERE id = $1", id)
|
||||
.execute(db)
|
||||
.await
|
||||
.into_diagnostic()
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
pub async fn new_song_model(db: &mut SqlitePool) -> Self {
|
||||
let mut model = Self {
|
||||
items: vec![],
|
||||
|
|
@ -1131,7 +952,7 @@ pub async fn update_song(
|
|||
.position(|current_song| current_song.id == song.id)
|
||||
.ok_or_else(|| miette!("Could not find song in model"))?;
|
||||
|
||||
replace(
|
||||
let _ = replace(
|
||||
songs
|
||||
.get_mut(index)
|
||||
.expect("We have found the song so this shouldn't fail"),
|
||||
|
|
@ -1565,7 +1386,7 @@ You saved my soul"
|
|||
let mut song = test_song();
|
||||
song.id = db_song.id;
|
||||
let conn = db.acquire().await.into_diagnostic()?;
|
||||
update_song_in_db(song, conn).await?;
|
||||
update_song(song, conn).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1640,7 +1461,7 @@ You saved my soul"
|
|||
let updated_model_song =
|
||||
song_model.find(|s| s.id == 7).unwrap();
|
||||
assert_eq!(&cloned_song, updated_model_song);
|
||||
match update_song_in_db(
|
||||
match update_song(
|
||||
cloned_song.clone(),
|
||||
db.acquire().await.unwrap(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,16 +10,13 @@ use super::{
|
|||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use miette::{IntoDiagnostic, Result, miette};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection,
|
||||
query, query_as,
|
||||
};
|
||||
use sqlx::{SqliteConnection, SqlitePool, query, query_as};
|
||||
use std::{
|
||||
mem::replace,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, Default, PartialEq, Serialize, Deserialize,
|
||||
|
|
@ -202,33 +199,6 @@ impl ServiceTrait for Video {
|
|||
}
|
||||
|
||||
impl Model<Video> {
|
||||
pub async fn append_video(
|
||||
&mut self,
|
||||
video: Video,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn new_video(&mut self, db: &SqlitePool) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn update_video(
|
||||
&mut self,
|
||||
video: Video,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn remove_video(
|
||||
&mut self,
|
||||
id: i32,
|
||||
db: &SqlitePool,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
pub async fn new_video_model(db: &mut SqlitePool) -> Self {
|
||||
let mut model = Self {
|
||||
items: vec![],
|
||||
|
|
@ -338,7 +308,7 @@ pub async fn update_video(
|
|||
.expect("We should have this video already")
|
||||
})?;
|
||||
|
||||
replace(current_video, video);
|
||||
let _ = replace(current_video, video);
|
||||
Ok(videos)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use cosmic::iced::{
|
|||
use cosmic::iced_core::text::Wrapping;
|
||||
use cosmic::iced_futures::Subscription;
|
||||
use cosmic::iced_widget::{column, row, stack};
|
||||
use cosmic::prelude::*;
|
||||
use cosmic::widget::dnd_destination::dnd_destination;
|
||||
use cosmic::widget::menu::key_bind::Modifier;
|
||||
use cosmic::widget::menu::{ItemWidth, KeyBind};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use cosmic::{
|
|||
};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use rapidfuzz::distance::levenshtein;
|
||||
use sqlx::{Sqlite, SqlitePool, migrate, pool::PoolConnection};
|
||||
use sqlx::{SqlitePool, migrate};
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::core::{
|
||||
|
|
@ -145,10 +145,6 @@ impl<'a> Library {
|
|||
self.song_library.get_item(index)
|
||||
}
|
||||
|
||||
async fn test(&mut self) -> Result<Song> {
|
||||
self.song_library.new_song(Arc::clone(&self.db)).await
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_possible_wrap)]
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
|
|
@ -208,7 +204,7 @@ impl<'a> Library {
|
|||
}
|
||||
Message::AddVideos(videos) => {
|
||||
debug!(?videos, "adding to db");
|
||||
let mut index = self.video_library.items.len();
|
||||
let _index = self.video_library.items.len();
|
||||
// Check if empty
|
||||
let mut tasks = Vec::new();
|
||||
let after_task =
|
||||
|
|
@ -226,10 +222,9 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|videos| {
|
||||
res.map_or(Message::None, |videos| {
|
||||
Message::ReaddVideos(videos)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
|
|
@ -254,22 +249,24 @@ impl<'a> Library {
|
|||
.collect();
|
||||
return Action::Task(Task::perform(
|
||||
presentations::add_presentation(
|
||||
vec![presentation.clone()],
|
||||
vec![presentation],
|
||||
presentations,
|
||||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|presentations| {
|
||||
Message::ReaddPres(presentations)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
res.map_or(
|
||||
Message::None,
|
||||
|presentations| {
|
||||
Message::ReaddPres(presentations)
|
||||
},
|
||||
)
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
Message::AddPresentations(presentations) => {
|
||||
debug!(?presentations, "adding to db");
|
||||
let mut index = self.presentation_library.items.len();
|
||||
let _index = self.presentation_library.items.len();
|
||||
// Check if empty
|
||||
let mut tasks = Vec::new();
|
||||
let after_task =
|
||||
|
|
@ -291,10 +288,12 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|presentations| {
|
||||
Message::ReaddPres(presentations)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
res.map_or(
|
||||
Message::None,
|
||||
|presentations| {
|
||||
Message::ReaddPres(presentations)
|
||||
},
|
||||
)
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
|
|
@ -305,7 +304,7 @@ impl<'a> Library {
|
|||
}
|
||||
Message::AddImages(images) => {
|
||||
debug!(?images, "adding to db");
|
||||
let mut index = self.image_library.items.len();
|
||||
let _index = self.image_library.items.len();
|
||||
// Check if empty
|
||||
let mut tasks = Vec::new();
|
||||
let after_task =
|
||||
|
|
@ -323,10 +322,9 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|images| {
|
||||
res.map_or(Message::None, |images| {
|
||||
Message::ReaddImages(images)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
|
|
@ -436,7 +434,7 @@ impl<'a> Library {
|
|||
return Action::DraggedItem(item);
|
||||
}
|
||||
Message::UpdateSong(song) => {
|
||||
let Some((kind, index)) = self.editing_item else {
|
||||
let Some((kind, _index)) = self.editing_item else {
|
||||
error!("Not editing an item");
|
||||
return Action::None;
|
||||
};
|
||||
|
|
@ -454,10 +452,7 @@ impl<'a> Library {
|
|||
songs,
|
||||
Arc::clone(&self.db),
|
||||
),
|
||||
|r| {
|
||||
r.map(|songs| Message::ReaddSongs(songs))
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
|r| r.map_or(Message::None, Message::ReaddSongs),
|
||||
));
|
||||
}
|
||||
Message::SongChanged => {
|
||||
|
|
@ -468,7 +463,7 @@ impl<'a> Library {
|
|||
self.image_library.items = images;
|
||||
}
|
||||
Message::UpdateImage(image) => {
|
||||
let Some((kind, index)) = self.editing_item else {
|
||||
let Some((kind, _index)) = self.editing_item else {
|
||||
error!("Not editing an item");
|
||||
return Action::None;
|
||||
};
|
||||
|
|
@ -486,10 +481,7 @@ impl<'a> Library {
|
|||
images,
|
||||
Arc::clone(&self.db),
|
||||
),
|
||||
|r| {
|
||||
r.map(|images| Message::ReaddImages(images))
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
|r| r.map_or(Message::None, Message::ReaddImages),
|
||||
));
|
||||
}
|
||||
Message::ImageChanged => (),
|
||||
|
|
@ -497,7 +489,7 @@ impl<'a> Library {
|
|||
self.video_library.items = videos;
|
||||
}
|
||||
Message::UpdateVideo(video) => {
|
||||
let Some((kind, index)) = self.editing_item else {
|
||||
let Some((kind, _index)) = self.editing_item else {
|
||||
error!("Not editing an item");
|
||||
return Action::None;
|
||||
};
|
||||
|
|
@ -516,10 +508,7 @@ impl<'a> Library {
|
|||
videos,
|
||||
Arc::clone(&self.db),
|
||||
),
|
||||
|r| {
|
||||
r.map(|videos| Message::ReaddVideos(videos))
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
|r| r.map_or(Message::None, Message::ReaddVideos),
|
||||
));
|
||||
}
|
||||
Message::VideoChanged => debug!("vid shoulda changed"),
|
||||
|
|
@ -550,10 +539,9 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
|r| {
|
||||
r.map(|presentations| {
|
||||
r.map_or(Message::None, |presentations| {
|
||||
Message::ReaddPres(presentations)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
));
|
||||
}
|
||||
|
|
@ -648,12 +636,14 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|videos| {
|
||||
Message::ReaddVideos(
|
||||
videos,
|
||||
)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
res.map_or(
|
||||
Message::None,
|
||||
|videos| {
|
||||
Message::ReaddVideos(
|
||||
videos,
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
|
|
@ -679,12 +669,14 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|images| {
|
||||
Message::ReaddImages(
|
||||
images,
|
||||
)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
res.map_or(
|
||||
Message::None,
|
||||
|images| {
|
||||
Message::ReaddImages(
|
||||
images,
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
|
|
@ -712,12 +704,14 @@ impl<'a> Library {
|
|||
Arc::clone(&self.db),
|
||||
),
|
||||
move |res| {
|
||||
res.map(|presentations| {
|
||||
Message::ReaddPres(
|
||||
presentations,
|
||||
)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
res.map_or(
|
||||
Message::None,
|
||||
|presentations| {
|
||||
Message::ReaddPres(
|
||||
presentations,
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
|
|
@ -1277,10 +1271,9 @@ impl<'a> Library {
|
|||
video.id,
|
||||
),
|
||||
|r| {
|
||||
r.map(|videos| {
|
||||
r.map_or(Message::None, |videos| {
|
||||
Message::ReaddVideos(videos)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
)
|
||||
} else {
|
||||
|
|
@ -1304,10 +1297,9 @@ impl<'a> Library {
|
|||
image.id,
|
||||
),
|
||||
|r| {
|
||||
r.map(|images| {
|
||||
r.map_or(Message::None, |images| {
|
||||
Message::ReaddImages(images)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
},
|
||||
)
|
||||
} else {
|
||||
|
|
@ -1331,10 +1323,14 @@ impl<'a> Library {
|
|||
presentation.id,
|
||||
),
|
||||
|r| {
|
||||
r.map(|presentations| {
|
||||
Message::ReaddPres(presentations)
|
||||
})
|
||||
.unwrap_or(Message::None)
|
||||
r.map_or(
|
||||
Message::None,
|
||||
|presentations| {
|
||||
Message::ReaddPres(
|
||||
presentations,
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use miette::{IntoDiagnostic, Result};
|
||||
use obws::{Client, responses::scenes::Scene};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use cosmic::{
|
|||
combo_box, container, divider, dnd_destination, dnd_source,
|
||||
dropdown,
|
||||
grid::{self},
|
||||
icon, mouse_area, popover, progress_bar, scrollable,
|
||||
icon, mouse_area, popover, scrollable,
|
||||
space::{self, horizontal},
|
||||
text, text_editor, text_input, tooltip,
|
||||
},
|
||||
|
|
@ -198,6 +198,7 @@ impl Display for Face {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
impl SongEditor {
|
||||
pub fn new(font_db: Arc<fontdb::Database>) -> Self {
|
||||
let fonts = font_dir();
|
||||
|
|
@ -1921,6 +1922,7 @@ impl SongEditor {
|
|||
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
#[allow(clippy::items_after_statements)]
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
fn verse_chip(
|
||||
verse: VerseName,
|
||||
index: Option<usize>,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ pub enum Action {
|
|||
None,
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
impl VerseEditor {
|
||||
#[must_use]
|
||||
pub fn new(verse: VerseName, lyric: &str) -> Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue