diff --git a/rslib/src/storage/tag/mod.rs b/rslib/src/storage/tag/mod.rs index 51e497835..8d9817856 100644 --- a/rslib/src/storage/tag/mod.rs +++ b/rslib/src/storage/tag/mod.rs @@ -30,6 +30,18 @@ impl SqliteStorage { .collect() } + /// Get all tags in human form, sorted by name + pub(crate) fn all_tags_sorted(&self) -> Result> { + self.db + .prepare_cached("select id, name, usn, config from tags order by name")? + .query_and_then(NO_PARAMS, |row| { + let mut tag = row_to_tag(row)?; + tag.name = native_tag_name_to_human(&tag.name); + Ok(tag) + })? + .collect() + } + /// Get tag by human name pub(crate) fn get_tag(&self, name: &str) -> Result> { self.db diff --git a/rslib/src/tags.rs b/rslib/src/tags.rs index 8468bc151..7b2621561 100644 --- a/rslib/src/tags.rs +++ b/rslib/src/tags.rs @@ -213,7 +213,7 @@ impl Collection { } pub fn tag_tree(&mut self) -> Result { - let tags = self.all_tags()?; + let tags = self.storage.all_tags_sorted()?; let tree = tags_to_tree(tags); Ok(tree)