Slightly throttle search index reload when calling add/remove in entrypoint generator

This commit is contained in:
Exidex 2024-12-28 21:00:20 +01:00
parent 11af8eaff2
commit f584f28a74
No known key found for this signature in database
GPG key ID: 46D8D21671EB48FA
4 changed files with 12 additions and 3 deletions

View file

@ -4,6 +4,9 @@
"scripts": {
"build": "tsc --noEmit && rollup --config rollup.config.ts --configPlugin typescript"
},
"dependencies": {
"@std/async": "npm:@jsr/std__async@^1.0.9"
},
"devDependencies": {
"@project-gauntlet/api": "*",
"@project-gauntlet/typings": "*",

View file

@ -8,6 +8,7 @@ import {
import { reloadSearchIndex } from "./search-index";
import type { FC } from "react";
import { renderView } from "./render";
import { throttle } from "@std/async/unstable-throttle";
interface GeneratedCommand { // TODO is it possible to import api here
name: string
@ -83,6 +84,8 @@ export async function runEntrypointGenerators(): Promise<void> {
await reloadSearchIndex(true)
const throttledReloadSearchIndex = throttle(() => reloadSearchIndex(true), 100)
const entrypointIds = await get_entrypoint_generator_entrypoint_ids();
for (const generatorEntrypointId of entrypointIds) {
try {
@ -138,7 +141,7 @@ export async function runEntrypointGenerators(): Promise<void> {
derivedActions,
}
reloadSearchIndex(true)
throttledReloadSearchIndex()
}
const remove = (id: string) => {
op_log_info("entrypoint_generator", `Removing entry '${id}' by entrypoint generator entrypoint '${generatorEntrypointId}'`)
@ -146,7 +149,7 @@ export async function runEntrypointGenerators(): Promise<void> {
delete storedGeneratedCommands[lookupId]
reloadSearchIndex(true)
throttledReloadSearchIndex()
}
const get = (id: string) => {

View file

@ -6,7 +6,7 @@
flake.overlays.default = final: _: let
# These must be updated following the instructions in ./nix/README.md when dependencies are updated or the version bumped
version = "v12";
npmDepsHash = "sha256-NADYbP3NUUezlMN5nPqZ3qpBRZNkSWf8HBwn9zqsEYw=";
npmDepsHash = "sha256-Y5IgbkaeKz4RYzgi3fdL1C0ztBZ0FNxvXcdtAnGMWgo=";
RUSTY_V8_ARCHIVE = fetchRustyV8 "130.0.2" {
aarch64-darwin = "sha256-aWZ/4Q4Wttx37xOdBmTCPGP+eYGhr4CM1UkYq8pC7Qs=";
aarch64-linux = "sha256-p9+tHmKIM5wBABubHIAstpwfzO19ypPzOuaV4b6loCU=";

3
package-lock.json generated
View file

@ -98,6 +98,9 @@
},
"js/core": {
"name": "@project-gauntlet/core",
"dependencies": {
"@std/async": "npm:@jsr/std__async@^1.0.9"
},
"devDependencies": {
"@project-gauntlet/api": "*",
"@project-gauntlet/typings": "*",