Skip to content

Commit

Permalink
fix: console error when adding or removing emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWoelki committed Dec 22, 2023
1 parent 9ba6bc7 commit 8eae12e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ export default class IconFolderPlugin extends Plugin {
},
});
this.saveInheritanceData(file.path, null);
removeIconFromIconPack(this, iconData.inheritanceIcon);
if (!emoji.isEmoji(iconData.inheritanceIcon)) {
removeIconFromIconPack(this, iconData.inheritanceIcon);
}
});
} else {
item.setTitle('Inherit icon');
Expand All @@ -184,7 +186,11 @@ export default class IconFolderPlugin extends Plugin {
this.saveInheritanceData(file.path, icon);
const iconName =
typeof icon === 'string' ? icon : icon.displayName;
saveIconToIconPack(this, iconName);

if (!emoji.isEmoji(iconName)) {
saveIconToIconPack(this, iconName);
}

inheritance.add(this, file.path, iconName, {
onAdd: (file) => {
if (this.getSettings().iconInTabsEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/icons-picker-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class IconsPickerModal extends FuzzySuggestModal<any> {
this.onSelect?.(iconNameWithPrefix);
this.plugin.addFolderIcon(this.path, item);
// Extracts the icon file to the icon pack.
if (typeof item === 'object') {
if (typeof item === 'object' && !emoji.isEmoji(iconNameWithPrefix)) {
saveIconToIconPack(this.plugin, iconNameWithPrefix);
}
this.plugin.notifyPlugins();
Expand Down

0 comments on commit 8eae12e

Please sign in to comment.