Equicord/src/equicordplugins/commandPalette/ui.tsx
Jake 1f3b9c9b9d
work in progress commandpalette (#790)
* okay, this is a long one. Initial commit to a long running list of commits and new features.

* multiple refactors, additions ect

* forgor to remove these

* Address Gemini's comments.

* small security fixes

* lord its done

* this has been ticking me off for a while

* lint

* fix(commandPalette): resolve stylelint specificity ordering

* general fixes

* refactor of query boxes

* fix query prompt offset

* fix: lint

* bunch bullshit

* Discard changes to package.json

* graph bullshit

* fix cursor offset

* more finnicky math bullshit

* variable support

* fixes

* fixes2

* but can it run doom?

* delete useless shit

* Delete assets/commandPaletteDoom directory

* more bullshit lol

* fixes

* fix: replace command palette doom runtime

* fix: localize bell dismiss icon

* fix(commandPalette): harden runtime behavior and typing

* fix(commandPalette): import React from webpack common

* fix(commandPalette): avoid React forwardRef dependency

---------

Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
2026-03-14 19:33:59 -04:00

34 lines
904 B
TypeScript

/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { closeModal, openModal } from "@utils/modal";
import { CommandPaletteModal } from "./ui/CommandPaletteModal";
let modalSerial = 0;
let activeModalKey: string | null = null;
export function openCommandPalette() {
if (activeModalKey) {
closeModal(activeModalKey);
activeModalKey = null;
return;
}
modalSerial += 1;
const modalKey = `equicord-command-palette-${modalSerial}`;
activeModalKey = openModal(
modalProps => <CommandPaletteModal modalProps={modalProps} instanceKey={modalSerial} />,
{
modalKey,
onCloseCallback: () => {
if (activeModalKey === modalKey) {
activeModalKey = null;
}
}
}
);
}