Skip to content

Commit

Permalink
fix: Fixed issue with viewing monster in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jan 13, 2022
1 parent 64c8b1c commit 1f90976
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/util/suggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class ViewMonsterModal extends Modal {
this.monster,
this.plugin,
false,
null,
this.plugin.defaultLayout
);
}
Expand Down
7 changes: 5 additions & 2 deletions src/view/Statblock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
export let statblock: StatblockItem[];
export let renderer: StatBlockRenderer;
export let layout: string;
export let icons: boolean = true;
let canExport = monster.export ?? plugin.settings.export;
let canDice =
Expand Down Expand Up @@ -67,7 +68,7 @@
observer.disconnect();
});
const icons = (node: HTMLElement) => {
const iconsEl = (node: HTMLElement) => {
new ExtraButtonComponent(node).setIcon("vertical-three-dots");
};
const menu = new Menu(plugin.app);
Expand Down Expand Up @@ -128,7 +129,9 @@
<span>Invalid monster.</span>
{/if}
</div>
<div class="icons" use:icons on:click={showMenu} />
{#if icons}
<div class="icons" use:iconsEl on:click={showMenu} />
{/if}
{/if}
</div>

Expand Down
10 changes: 6 additions & 4 deletions src/view/statblock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { Monster } from "@types";
import Statblock from "./Statblock.svelte";
import type StatBlockPlugin from "src/main";

import fastCopy from "fast-copy";

export default class StatBlockRenderer extends MarkdownRenderChild {
topBar: HTMLDivElement;
bottomBar: HTMLDivElement;
Expand All @@ -20,7 +22,7 @@ export default class StatBlockRenderer extends MarkdownRenderChild {
container: HTMLElement,
public monster: Monster,
private plugin: StatBlockPlugin,
private canSave: boolean,
private icons: boolean,
public context: string,
public layout: Layout = Layout5e
) {
Expand All @@ -34,20 +36,20 @@ export default class StatBlockRenderer extends MarkdownRenderChild {
statblock: this.layout.blocks,
layout: this.layout.name,
plugin: this.plugin,
renderer: this
renderer: this,
icons: this.icons
}
});
statblock.$on("save", async () => {
if (
!this.canSave &&
!(await confirmWithModal(
this.plugin.app,
"This will overwrite an existing monster in settings. Are you sure?"
))
)
return;
this.plugin.saveMonster({
...this.monster,
...fastCopy(this.monster),
source: "Homebrew"
});
});
Expand Down

0 comments on commit 1f90976

Please sign in to comment.