mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
fix(core): clearing an undefined type's icon defines nothing
Also covers that renaming a plain tag leaves an undefined (suggested) type of that name alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bd2236bb89
commit
872073a0a0
2 files changed
+27
-3
No files matched your search
@@ -245,8 +245,8 @@ impl Graph {
|
||||
Ok(name)
|
||||
}
|
||||
|
||||
/// Sets (or with `None` clears) the emoji of a type, defining the type if needed (see
|
||||
/// [`normalize_icon`] for what an icon may be).
|
||||
/// Sets (or with `None` clears) the emoji of a type, defining the type when setting one
|
||||
/// (see [`normalize_icon`] for what an icon may be). Clearing an undefined type is a no-op.
|
||||
pub fn set_type_icon(&self, name: &str, icon: Option<&str>) -> Result<()> {
|
||||
let name = checked_type_name(name)?;
|
||||
let icon = match icon {
|
||||
@@ -255,7 +255,8 @@ impl Graph {
|
||||
};
|
||||
let tx = self.tx()?;
|
||||
let current = self.type_def(&name)?.filter(|d| !d.removed);
|
||||
if current.as_ref().is_some_and(|d| d.icon == icon) {
|
||||
// Clearing the icon of an undefined type changes nothing (and defines nothing).
|
||||
if current.as_ref().map_or(icon.is_none(), |d| d.icon == icon) {
|
||||
tx.commit()?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user