some clippy fixes
This commit is contained in:
parent
3b1a0c4207
commit
46abd9dd7a
13 changed files with 54 additions and 85 deletions
|
|
@ -211,7 +211,7 @@ pub async fn update_image_in_db(
|
|||
.map(std::string::ToString::to_string)
|
||||
.unwrap_or_default();
|
||||
let mut db = db.detach();
|
||||
let id = image.id.clone();
|
||||
let id = image.id;
|
||||
if let Err(e) = query!("SELECT id FROM images where id = $1", id)
|
||||
.fetch_one(&mut db)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ pub async fn update_presentation_in_db(
|
|||
.unwrap_or_default();
|
||||
let html = presentation.kind == PresKind::Html;
|
||||
let mut db = db.detach();
|
||||
let id = presentation.id.clone();
|
||||
let id = presentation.id;
|
||||
if let Err(e) =
|
||||
query!("SELECT id FROM presentations where id = $1", id)
|
||||
.fetch_one(&mut db)
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ pub async fn update_video_in_db(
|
|||
.map(std::string::ToString::to_string)
|
||||
.unwrap_or_default();
|
||||
let mut db = db.detach();
|
||||
let id = video.id.clone();
|
||||
let id = video.id;
|
||||
if let Err(e) = query!("SELECT id FROM videos where id = $1", id)
|
||||
.fetch_one(&mut db)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -765,7 +765,7 @@ impl cosmic::Application for App {
|
|||
})
|
||||
}
|
||||
song_editor::Action::UpdateSong(song) => {
|
||||
if let Some(_) = &mut self.library {
|
||||
if self.library.is_some() {
|
||||
self.update(Message::Library(
|
||||
library::Message::UpdateSong(song),
|
||||
))
|
||||
|
|
@ -786,7 +786,7 @@ impl cosmic::Application for App {
|
|||
})
|
||||
}
|
||||
image_editor::Action::UpdateImage(image) => {
|
||||
if let Some(_) = &mut self.library {
|
||||
if self.library.is_some() {
|
||||
self.update(Message::Library(
|
||||
library::Message::UpdateImage(image),
|
||||
))
|
||||
|
|
@ -807,7 +807,7 @@ impl cosmic::Application for App {
|
|||
})
|
||||
}
|
||||
video_editor::Action::UpdateVideo(video) => {
|
||||
if let Some(_) = &mut self.library {
|
||||
if self.library.is_some() {
|
||||
self.update(Message::Library(
|
||||
library::Message::UpdateVideo(video),
|
||||
))
|
||||
|
|
@ -1732,8 +1732,7 @@ where
|
|||
moved_item_overlay: Color::from(
|
||||
t.cosmic().primary.base,
|
||||
)
|
||||
.scale_alpha(0.2)
|
||||
.into(),
|
||||
.scale_alpha(0.2),
|
||||
ghost_border: Border {
|
||||
width: 1.0,
|
||||
color: t.cosmic().secondary.base.into(),
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ impl ImageEditor {
|
|||
.image
|
||||
.as_ref()
|
||||
.map(|v| v.id)
|
||||
.unwrap_or_default()
|
||||
.clone();
|
||||
.unwrap_or_default();
|
||||
let task = Task::perform(
|
||||
pick_image(),
|
||||
move |image_result| {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use cosmic::{
|
|||
},
|
||||
Element, Task,
|
||||
};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use rapidfuzz::distance::levenshtein;
|
||||
use sqlx::{migrate, SqlitePool};
|
||||
use tracing::{debug, error, warn};
|
||||
|
|
@ -156,13 +156,13 @@ impl<'a> Library {
|
|||
LibraryKind::Video => {
|
||||
return Action::Task(Task::perform(
|
||||
add_videos(),
|
||||
|videos| Message::AddVideos(videos),
|
||||
Message::AddVideos,
|
||||
));
|
||||
}
|
||||
LibraryKind::Image => {
|
||||
return Action::Task(Task::perform(
|
||||
add_images(),
|
||||
|images| Message::AddImages(images),
|
||||
Message::AddImages,
|
||||
));
|
||||
}
|
||||
LibraryKind::Presentation => {
|
||||
|
|
@ -248,13 +248,12 @@ impl<'a> Library {
|
|||
let Some(first_item) = self
|
||||
.selected_items
|
||||
.as_ref()
|
||||
.map(|items| {
|
||||
.and_then(|items| {
|
||||
items
|
||||
.iter()
|
||||
.next()
|
||||
.map(|(_, index)| index)
|
||||
})
|
||||
.flatten()
|
||||
else {
|
||||
let Some(item) = item else {
|
||||
return Action::None;
|
||||
|
|
@ -270,9 +269,9 @@ impl<'a> Library {
|
|||
self.selected_items = self
|
||||
.selected_items
|
||||
.clone()
|
||||
.and_then(|mut items| {
|
||||
.map(|mut items| {
|
||||
items.push((kind, id));
|
||||
Some(items)
|
||||
items
|
||||
});
|
||||
}
|
||||
} else if first_item > &index {
|
||||
|
|
@ -280,9 +279,9 @@ impl<'a> Library {
|
|||
self.selected_items = self
|
||||
.selected_items
|
||||
.clone()
|
||||
.and_then(|mut items| {
|
||||
.map(|mut items| {
|
||||
items.push((kind, id));
|
||||
Some(items)
|
||||
items
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -908,25 +907,21 @@ impl<'a> Library {
|
|||
error!(?e);
|
||||
Task::none()
|
||||
} else {
|
||||
let task =
|
||||
Task::future(self.db.acquire())
|
||||
|
||||
Task::future(self.db.acquire())
|
||||
.and_then(move |db| {
|
||||
Task::perform(
|
||||
songs::remove_from_db(
|
||||
db, song.id,
|
||||
),
|
||||
|r| {
|
||||
match r {
|
||||
Err(e) => {
|
||||
error!(?e)
|
||||
}
|
||||
_ => (),
|
||||
if let Err(e) = r {
|
||||
error!(?e)
|
||||
}
|
||||
Message::None
|
||||
},
|
||||
)
|
||||
});
|
||||
task
|
||||
})
|
||||
}
|
||||
} else {
|
||||
Task::none()
|
||||
|
|
@ -943,25 +938,21 @@ impl<'a> Library {
|
|||
error!(?e);
|
||||
Task::none()
|
||||
} else {
|
||||
let task =
|
||||
Task::future(self.db.acquire())
|
||||
|
||||
Task::future(self.db.acquire())
|
||||
.and_then(move |db| {
|
||||
Task::perform(
|
||||
videos::remove_from_db(
|
||||
db, video.id,
|
||||
),
|
||||
|r| {
|
||||
match r {
|
||||
Err(e) => {
|
||||
error!(?e)
|
||||
}
|
||||
_ => (),
|
||||
if let Err(e) = r {
|
||||
error!(?e)
|
||||
}
|
||||
Message::None
|
||||
},
|
||||
)
|
||||
});
|
||||
task
|
||||
})
|
||||
}
|
||||
} else {
|
||||
Task::none()
|
||||
|
|
@ -978,25 +969,21 @@ impl<'a> Library {
|
|||
error!(?e);
|
||||
Task::none()
|
||||
} else {
|
||||
let task =
|
||||
Task::future(self.db.acquire())
|
||||
|
||||
Task::future(self.db.acquire())
|
||||
.and_then(move |db| {
|
||||
Task::perform(
|
||||
images::remove_from_db(
|
||||
db, image.id,
|
||||
),
|
||||
|r| {
|
||||
match r {
|
||||
Err(e) => {
|
||||
error!(?e)
|
||||
}
|
||||
_ => (),
|
||||
if let Err(e) = r {
|
||||
error!(?e)
|
||||
}
|
||||
Message::None
|
||||
},
|
||||
)
|
||||
});
|
||||
task
|
||||
})
|
||||
}
|
||||
} else {
|
||||
Task::none()
|
||||
|
|
@ -1014,8 +1001,8 @@ impl<'a> Library {
|
|||
error!(?e);
|
||||
Task::none()
|
||||
} else {
|
||||
let task =
|
||||
Task::future(self.db.acquire())
|
||||
|
||||
Task::future(self.db.acquire())
|
||||
.and_then(move |db| {
|
||||
Task::perform(
|
||||
presentations::remove_from_db(
|
||||
|
|
@ -1023,17 +1010,13 @@ impl<'a> Library {
|
|||
presentation.id,
|
||||
),
|
||||
|r| {
|
||||
match r {
|
||||
Err(e) => {
|
||||
error!(?e)
|
||||
}
|
||||
_ => (),
|
||||
if let Err(e) = r {
|
||||
error!(?e)
|
||||
}
|
||||
Message::None
|
||||
},
|
||||
)
|
||||
});
|
||||
task
|
||||
})
|
||||
}
|
||||
} else {
|
||||
Task::none()
|
||||
|
|
@ -1041,7 +1024,7 @@ impl<'a> Library {
|
|||
}
|
||||
})
|
||||
.collect();
|
||||
if tasks.len() > 0 {
|
||||
if !tasks.is_empty() {
|
||||
self.selected_items = None;
|
||||
}
|
||||
Action::Task(Task::batch(tasks))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use cosmic::{
|
|||
iced_widget::{column, row},
|
||||
theme,
|
||||
widget::{
|
||||
self, button, container, horizontal_space, icon, text,
|
||||
button, container, horizontal_space, icon, text,
|
||||
text_input, Space,
|
||||
},
|
||||
Element, Task,
|
||||
|
|
@ -83,8 +83,7 @@ impl PresentationEditor {
|
|||
.presentation
|
||||
.as_ref()
|
||||
.map(|v| v.id)
|
||||
.unwrap_or_default()
|
||||
.clone();
|
||||
.unwrap_or_default();
|
||||
let task = Task::perform(
|
||||
pick_presentation(),
|
||||
move |presentation_result| {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use crate::{
|
|||
|
||||
const REFERENCE_WIDTH: f32 = 1920.0;
|
||||
static DEFAULT_SLIDE: LazyLock<Slide> =
|
||||
LazyLock::new(|| Slide::default());
|
||||
LazyLock::new(Slide::default);
|
||||
|
||||
// #[derive(Default, Clone, Debug)]
|
||||
pub(crate) struct Presenter {
|
||||
|
|
@ -155,11 +155,9 @@ impl Presenter {
|
|||
items.iter().fold(0, |a, item| a + item.slides.len());
|
||||
|
||||
let slide =
|
||||
items.get(0).map(|item| item.slides.get(0)).flatten();
|
||||
let audio = items
|
||||
.get(0)
|
||||
.map(|item| item.slides.get(0).map(|slide| slide.audio()))
|
||||
.flatten()
|
||||
items.first().and_then(|item| item.slides.first());
|
||||
let audio = items.first()
|
||||
.and_then(|item| item.slides.first().map(|slide| slide.audio()))
|
||||
.flatten();
|
||||
|
||||
Self {
|
||||
|
|
@ -179,7 +177,7 @@ impl Presenter {
|
|||
.expect("Can't open default rodio stream");
|
||||
(
|
||||
Arc::new(Sink::connect_new(
|
||||
&stream_handle.mixer(),
|
||||
stream_handle.mixer(),
|
||||
)),
|
||||
stream_handle,
|
||||
)
|
||||
|
|
@ -219,8 +217,7 @@ impl Presenter {
|
|||
if let Some(slide) = self
|
||||
.service
|
||||
.get(item_index)
|
||||
.map(|item| item.slides.get(slide_index))
|
||||
.flatten()
|
||||
.and_then(|item| item.slides.get(slide_index))
|
||||
{
|
||||
self.current_item = item_index;
|
||||
self.current_slide_index = slide_index;
|
||||
|
|
@ -473,7 +470,7 @@ impl Presenter {
|
|||
);
|
||||
|
||||
let container = slide_view(
|
||||
&slide,
|
||||
slide,
|
||||
&self.video,
|
||||
true,
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use cosmic::{
|
|||
event, mouse, Event, Length, Point, Rectangle, Vector,
|
||||
},
|
||||
iced_core::{
|
||||
self, image::Renderer, layout, renderer, widget::Tree,
|
||||
self, layout, renderer, widget::Tree,
|
||||
Clipboard, Shell,
|
||||
},
|
||||
widget::Widget,
|
||||
|
|
@ -196,8 +196,7 @@ impl<Message: Clone + 'static>
|
|||
// We ignore motion if we do not possess drag content by now.
|
||||
if let Some(left_pressed_position) =
|
||||
state.left_pressed_position
|
||||
{
|
||||
if position
|
||||
&& position
|
||||
.distance(left_pressed_position)
|
||||
> self.drag_threshold
|
||||
{
|
||||
|
|
@ -217,7 +216,6 @@ impl<Message: Clone + 'static>
|
|||
state.left_pressed_position =
|
||||
None;
|
||||
}
|
||||
}
|
||||
if !cursor.is_over(layout.bounds()) {
|
||||
state.hovered = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -308,12 +308,12 @@ impl SongEditor {
|
|||
fn slide_preview(&self) -> Element<Message> {
|
||||
if let Some(slides) = &self.song_slides {
|
||||
let slides: Vec<Element<Message>> = slides
|
||||
.into_iter()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, slide)| {
|
||||
container(
|
||||
slide_view(
|
||||
&slide,
|
||||
slide,
|
||||
if index == 0 {
|
||||
&self.video
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ impl VideoEditor {
|
|||
.core_video
|
||||
.as_ref()
|
||||
.map(|v| v.id)
|
||||
.unwrap_or_default()
|
||||
.clone();
|
||||
.unwrap_or_default();
|
||||
let task = Task::perform(
|
||||
pick_video(),
|
||||
move |video_result| {
|
||||
|
|
|
|||
|
|
@ -468,8 +468,7 @@ where
|
|||
Action::Picking { index, origin } => {
|
||||
if let Some(cursor_position) =
|
||||
cursor.position()
|
||||
{
|
||||
if cursor_position.distance(origin)
|
||||
&& cursor_position.distance(origin)
|
||||
> self.deadband_zone
|
||||
{
|
||||
// Start dragging
|
||||
|
|
@ -488,7 +487,6 @@ where
|
|||
event_status =
|
||||
event::Status::Captured;
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::Dragging { origin, index, .. } => {
|
||||
if let Some(cursor_position) =
|
||||
|
|
@ -903,8 +901,7 @@ pub fn default(theme: &Theme) -> Style {
|
|||
Style {
|
||||
scale: 1.05,
|
||||
moved_item_overlay: Color::from(theme.cosmic().primary.base)
|
||||
.scale_alpha(0.2)
|
||||
.into(),
|
||||
.scale_alpha(0.2),
|
||||
ghost_border: Border {
|
||||
width: 1.0,
|
||||
color: theme.cosmic().secondary.base.into(),
|
||||
|
|
|
|||
|
|
@ -454,8 +454,7 @@ where
|
|||
Action::Picking { index, origin } => {
|
||||
if let Some(cursor_position) =
|
||||
cursor.position()
|
||||
{
|
||||
if cursor_position.distance(origin)
|
||||
&& cursor_position.distance(origin)
|
||||
> self.deadband_zone
|
||||
{
|
||||
// Start dragging
|
||||
|
|
@ -474,7 +473,6 @@ where
|
|||
event_status =
|
||||
event::Status::Captured;
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::Dragging { origin, index, .. } => {
|
||||
if let Some(cursor_position) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue