Skip to content

Commit

Permalink
fix(pack-manager): change icon dir to .obsidian/icons to avoid sync c…
Browse files Browse the repository at this point in the history
…onflict; fix failed to load when customIconsDir not exist
  • Loading branch information
aidenlx committed Nov 17, 2021
1 parent 574c084 commit 76c93ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/icon-packs/pack-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from "./utils";

const CUSTOM_ICON_PATH = "/icons.json";
const CUSTOM_ICON_DIR = "themes/icons";
const CUSTOM_ICON_DIR = "icons";

export default class PackManager extends Events {
private _customIcons = new Map<string, FileIconInfo>();
Expand Down Expand Up @@ -130,6 +130,10 @@ export default class PackManager extends Events {
private _loaded = false;
async loadCustomIcons(): Promise<void> {
if (this._loaded) return;
if (!(await this.vault.adapter.exists(this.customIconsDir))) {
await this.vault.adapter.mkdir(this.customIconsDir);
return;
}
const iconlist = await this.vault.adapter.list(this.customIconsDir);

let info;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/json-to-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const tryUpdateIcons = async (plugin: IconSC) => {
plugin.settings.isMigrated = true;
await plugin.saveSettings();
new Notice(
"Icon update complete, you can now find icon files in .obsidian/themes/icons",
"Icon update complete, you can now find icon files in " +
plugin.packManager.customIconsDir,
);
} catch (error) {
new Notice("Failed to update icons, check console for more details");
Expand Down

0 comments on commit 76c93ff

Please sign in to comment.