Skip to content

Commit

Permalink
fix: fixes issue with creating a new layout from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jan 13, 2022
1 parent e0fec78 commit 860aeac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,14 @@ export default class StatblockSettingTab extends PluginSettingTab {
.setTooltip("Add New Statblock")
.onClick(() => {
const modal = new CreateStatblockModal(this.plugin);
modal.onClose = async () => {
if (!modal.saved) return;
this.plugin.settings.layouts.push(
this.getDuplicate(modal.layout)
);
await this.plugin.saveSettings();
this.buildCustomLayouts(layoutContainer);
};
modal.open();
})
);
Expand Down Expand Up @@ -483,6 +491,8 @@ export default class StatblockSettingTab extends PluginSettingTab {
this.buildCustomLayouts(layoutContainer);
}
getDuplicate(layout: Layout) {
if (!this.plugin.settings.layouts.find((l) => l.name == layout.name))
return layout;
const names = this.plugin.settings.layouts
.filter((l) => l.name.contains(`${layout.name} Copy`))
.map((l) => l.name);
Expand Down

0 comments on commit 860aeac

Please sign in to comment.