use crate::ui::{Id, IdTagEditor, Model, TEMsg, TFMsg};
impl Model {
pub fn update_tageditor(&mut self, msg: &TEMsg) {
match msg {
TEMsg::TagEditorRun(node_id) => {
self.mount_tageditor(node_id);
}
TEMsg::TagEditorClose(_song) => {
if let Some(s) = self.tageditor_song.clone() {
self.library_reload_with_node_focus(s.file());
}
self.umount_tageditor();
}
TEMsg::TECounterDeleteOk => {
self.te_delete_lyric();
}
TEMsg::TESelectLyricOk(index) => {
if let Some(mut song) = self.tageditor_song.clone() {
song.set_lyric_selected_index(*index);
self.init_by_song(&song);
}
}
TEMsg::TESearch => {
self.te_songtag_search();
}
TEMsg::TEDownload(index) => {
if let Err(e) = self.te_songtag_download(*index) {
self.mount_error_popup(format!("download song by tag error: {e}"));
}
}
TEMsg::TEEmbed(index) => {
if let Err(e) = self.te_load_lyric_and_photo(*index) {
self.mount_error_popup(format!("embed error: {e}"));
}
}
TEMsg::TERename => {
if let Err(e) = self.te_rename_song_by_tag() {
self.mount_error_popup(format!("rename song by tag error: {e}"));
}
}
TEMsg::TEFocus(m) => self.update_tag_editor_focus(m),
}
}
fn update_tag_editor_focus(&mut self, msg: &TFMsg) {
match msg {
TFMsg::TextareaLyricBlurDown | TFMsg::InputTitleBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::InputArtist))
.ok();
}
TFMsg::InputArtistBlurDown | TFMsg::InputAlbumBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::InputTitle))
.ok();
}
TFMsg::InputTitleBlurDown | TFMsg::InputGenreBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::InputAlbum))
.ok();
}
TFMsg::InputAlbumBlurDown | TFMsg::TableLyricOptionsBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::InputGenre))
.ok();
}
TFMsg::InputGenreBlurDown | TFMsg::SelectLyricBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::TableLyricOptions))
.ok();
}
TFMsg::TableLyricOptionsBlurDown | TFMsg::CounterDeleteBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::SelectLyric))
.ok();
}
TFMsg::SelectLyricBlurDown | TFMsg::TextareaLyricBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::CounterDelete))
.ok();
}
TFMsg::CounterDeleteBlurDown | TFMsg::InputArtistBlurUp => {
self.app
.active(&Id::TagEditor(IdTagEditor::TextareaLyric))
.ok();
}
}
}
}