[fix]: performance issue by creating service_item on mouse hovers
Some checks failed
/ clippy (push) Failing after 5m6s
/ test (push) Failing after 5m48s

This commit is contained in:
Chris Cochrun 2026-04-10 13:08:38 -05:00
parent 62a631873d
commit 22c9b02fbc
2 changed files with 35 additions and 6 deletions

View file

@ -28,8 +28,6 @@ There seems to be some issue with fontdb not able to decipher all the versions o
* TODO [#B] Find a way to use auth-token in tests for ci
If I can find out how to use my secrets in ci that would free up more tests, but I could also just turn that test off for the CI so that it won't constantly fail for now
* TODO [#C] Rename menu actions to menu commands and build a reverse hashmap for settings to map commands to key-binding such that we can allow for remapping them on the fly.
* TODO [#B] Saving and loading font awareness
Someday we should make the saving and loading to be aware of the fonts on the system and find a way to embed them into the save file.
@ -37,6 +35,8 @@ Someday we should make the saving and loading to be aware of the fonts on the sy
* TODO [#B] Develop library system for slides that are more than images or video i.e. content
* TODO [#C] Rename menu actions to menu commands and build a reverse hashmap for settings to map commands to key-binding such that we can allow for remapping them on the fly.
* TODO [#C] Use orgize as a file parser and allow for orgdown files to represent a presentation.
Orgize has some very nice features that will let me determine what things are in an orgdown file and thus take said file and turn it into a presentation.
@ -109,6 +109,10 @@ There is likely some work that still needs to be done here, I believe I am someh
* DONE [#A] Need to fixup how songs are edited in the editors
Currently the song is cloned many times to pass around and then finally get updated in DB. Instead, we need to edit the song directly in the editor and after it's been changed appropriatel, run the update_song method to get the current song and create slides from it and then update it in the DB.
* DONE Song Editor has some sort of performance issue.
CLOSED: [2026-04-10 Fri 13:08]
=core::songs= logs in line 294 whenever even mousing over the song editor.
* DONE [#B] Functions for text alignments
This will need to be matched on for the =TextAlignment= from the user

View file

@ -111,7 +111,7 @@ pub enum Message {
ReaddImages(Vec<Image>),
ReaddVideos(Vec<Video>),
ReaddPres(Vec<Presentation>),
ToService(ServiceItem),
ToService((LibraryKind, i32)),
}
impl<'a> Library {
@ -156,8 +156,30 @@ impl<'a> Library {
pub fn update(&mut self, message: Message) -> Action {
match message {
Message::None => (),
Message::ToService(item) => {
return Action::ToService(item);
Message::ToService((kind, index)) => {
let item = match kind {
LibraryKind::Song => self
.song_library
.get_item(index)
.map(|song| song.to_service_item()),
LibraryKind::Video => self
.video_library
.get_item(index)
.map(|video| video.to_service_item()),
LibraryKind::Image => self
.image_library
.get_item(index)
.map(|image| image.to_service_item()),
LibraryKind::Presentation => self
.presentation_library
.get_item(index)
.map(|presentation| {
presentation.to_service_item()
}),
};
if let Some(item) = item {
return Action::ToService(item);
};
}
Message::DeleteItem => {
return self.delete_items();
@ -1060,7 +1082,10 @@ impl<'a> Library {
let texts = column([text.into(), subtext.into()]);
let add_button = button::icon(icon::from_name("arrow-right"))
.on_press(Message::ToService(item.to_service_item()))
.on_press(Message::ToService((
model.kind,
index.try_into().expect("Shouldn't have issues"),
)))
.tooltip("Add to service");
Container::new(