Skip to content

Commit

Permalink
Show confirmation modal when deleting from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
phibr0 committed Jun 13, 2022
1 parent 995baf9 commit 9c58a1b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "cmdr",
"name": "Commander",
"version": "0.0.4",
"version": "0.0.5",
"minAppVersion": "0.12.0",
"description": "Customize your workspace by adding commands /everywhere/.",
"author": "jsmorabito & phibr0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cmdr",
"version": "0.0.4",
"version": "0.0.5",
"description": "Customize your workspace by adding commands /everywhere/.",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/commander-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
svg {
width: 100%;
}

> .cmdr-icon-wrapper {
width: 196px;
}
}

.cmdr-add-new-wrapper {
Expand Down
7 changes: 6 additions & 1 deletion src/ui/components/commandViewerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { arrayMoveMutable } from "array-move";
import { useEffect, useRef } from "preact/hooks";
import { setIcon } from "obsidian";
import ChooseIconModal from "../chooseIconModal";
import ConfirmDeleteModal from "../confirmDeleteModal";

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
export const ManagerContext = createContext<CommandManager>(null!);
Expand All @@ -32,7 +33,11 @@ export default function CommandViewer({ manager, plugin }: CommandViewerProps):
return <CommandComponent
key={cmd.id}
pair={cmd}
handleRemove={async (): Promise<void> => { await manager.removeCommand(cmd); this.forceUpdate(); }}
handleRemove={async (): Promise<void> => {
if (!plugin.settings.confirmDeletion || await new ConfirmDeleteModal(plugin).didChooseRemove()) {
await manager.removeCommand(cmd); this.forceUpdate();
}
}}
handleUp={(): void => { arrayMoveMutable(manager.pairs, idx, idx - 1); manager.reorder(); this.forceUpdate(); }}
handleDown={(): void => { arrayMoveMutable(manager.pairs, idx, idx + 1); manager.reorder(); this.forceUpdate(); }}
handleRename={async (name): Promise<void> => { cmd.name = name; await plugin.saveSettings(); manager.reorder(); this.forceUpdate(); }}
Expand Down

0 comments on commit 9c58a1b

Please sign in to comment.