mirror of
https://github.com/jsmorabito/obsidian-commander.git
synced 2026-07-22 06:40:31 +00:00
Hide commands of other devices, fix support button not working on mobile because of electron dependency
This commit is contained in:
parent
d9a69e0c26
commit
c655cfffd6
4 changed files with 36 additions and 36 deletions
|
|
@ -28,7 +28,7 @@ export default function CommandComponent({ pair, handleRemove, handleDown, handl
|
|||
const isChecked = cmd.hasOwnProperty("checkCallback") || cmd.hasOwnProperty("editorCheckCallback");
|
||||
|
||||
const modeIcon = getModeIcon(pair.mode);
|
||||
const modeName = pair.mode.match(/desktop|mobile|any/) ? pair.mode[0].toUpperCase() + pair.mode.substring(1) : `Device ${pair.mode}`;
|
||||
const modeName = pair.mode.match(/desktop|mobile|any/) ? pair.mode[0].toUpperCase() + pair.mode.substring(1) : `This device`;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@ import CommanderPlugin from "src/main";
|
|||
import CommandComponent from "./commandComponent";
|
||||
import logo from "src/assets/commander-logo.svg";
|
||||
import CommandManager from "src/manager/_commandManager";
|
||||
import { chooseNewCommand } from "src/util";
|
||||
import { chooseNewCommand, isModeActive } from "src/util";
|
||||
import { arrayMoveMutable } from "array-move";
|
||||
import ChooseIconModal from "../chooseIconModal";
|
||||
import ConfirmDeleteModal from "../confirmDeleteModal";
|
||||
import { CommandIconPair } from "src/types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
export const ManagerContext = createContext<CommandManager>(null!);
|
||||
|
|
@ -20,41 +21,42 @@ export default function CommandViewer({ manager, plugin }: CommandViewerProps):
|
|||
<Fragment>
|
||||
<ManagerContext.Provider value={manager}>
|
||||
{manager.pairs.map((cmd, idx) => {
|
||||
return <CommandComponent
|
||||
key={cmd.id}
|
||||
pair={cmd}
|
||||
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(); }}
|
||||
handleNewIcon={async (): Promise<void> => {
|
||||
const newIcon = await (new ChooseIconModal(plugin)).awaitSelection();
|
||||
if (newIcon && newIcon !== cmd.icon) {
|
||||
cmd.icon = newIcon;
|
||||
if (cmd.mode.match(/desktop|mobile|any/) || cmd.mode === app.appId) {
|
||||
return <CommandComponent
|
||||
key={cmd.id}
|
||||
pair={cmd}
|
||||
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(); }}
|
||||
handleNewIcon={async (): Promise<void> => {
|
||||
const newIcon = await (new ChooseIconModal(plugin)).awaitSelection();
|
||||
if (newIcon && newIcon !== cmd.icon) {
|
||||
cmd.icon = newIcon;
|
||||
await plugin.saveSettings();
|
||||
manager.reorder();
|
||||
this.forceUpdate();
|
||||
}
|
||||
}}
|
||||
handleModeChange={async (): Promise<void> => {
|
||||
// This is the rotation
|
||||
const modes = ["any", "desktop", "mobile", app.appId];
|
||||
let currentIdx = modes.indexOf(cmd.mode);
|
||||
if (currentIdx === 3) currentIdx = -1;
|
||||
|
||||
cmd.mode = modes[currentIdx + 1];
|
||||
await plugin.saveSettings();
|
||||
manager.reorder();
|
||||
this.forceUpdate();
|
||||
}
|
||||
}}
|
||||
handleModeChange={async (): Promise<void> => {
|
||||
// This is the rotation
|
||||
const modes = ["any", "desktop", "mobile", app.appId];
|
||||
let currentIdx = modes.indexOf(cmd.mode);
|
||||
if (currentIdx === 3) currentIdx = -1;
|
||||
|
||||
cmd.mode = modes[currentIdx + 1];
|
||||
await plugin.saveSettings();
|
||||
manager.reorder();
|
||||
this.forceUpdate();
|
||||
}}
|
||||
/>;
|
||||
}}
|
||||
/>;
|
||||
}
|
||||
})}
|
||||
|
||||
{manager.pairs.length === 0 && <div class="cmdr-commands-empty">
|
||||
{!manager.pairs.some((pre) => isModeActive(pre.mode)) && <div class="cmdr-commands-empty">
|
||||
{/* This isn't really dangerous,
|
||||
as the svg is inserted at build time and no other data can be passed to it */}
|
||||
<div class="cmdr-icon-wrapper" dangerouslySetInnerHTML={{ __html: logo }} />
|
||||
|
|
|
|||
|
|
@ -123,8 +123,7 @@ export default function settingTabComponent({ plugin, mobileMode }: { plugin: Co
|
|||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const pos = coffeeIcon.current!.getBoundingClientRect();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
setTimeout(() => require('electron').shell.openExternal("https://buymeacoffee.com/phibr0"), 800);
|
||||
setTimeout(() => location.replace("https://buymeacoffee.com/phibr0"), 800);
|
||||
|
||||
await myConfetti({
|
||||
particleCount: 150,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import { Command, setIcon } from 'obsidian';
|
|||
import ChooseCustomNameModal from './ui/chooseCustomNameModal';
|
||||
import { ComponentProps, h } from 'preact';
|
||||
import { useRef, useEffect } from 'preact/hooks';
|
||||
import { HTMLAttributes } from 'react';
|
||||
|
||||
/**
|
||||
* It creates a modal, waits for the user to select a command, and then creates another modal to wait
|
||||
|
|
|
|||
Loading…
Reference in a new issue