1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix catalog syncer long delay (#4911)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2022-02-23 06:52:43 +02:00 committed by GitHub
parent 9c604dcfa1
commit 12a6bd8512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -14,9 +14,13 @@ import { catalogInitChannel, catalogItemsChannel } from "../common/ipc/catalog";
const broadcaster = debounce((items: CatalogEntity[]) => { const broadcaster = debounce((items: CatalogEntity[]) => {
broadcastMessage(catalogItemsChannel, items); broadcastMessage(catalogItemsChannel, items);
}, 1_000, { leading: true, trailing: true }); }, 100, { leading: true, trailing: true });
export function pushCatalogToRenderer(catalog: CatalogEntityRegistry) { export function pushCatalogToRenderer(catalog: CatalogEntityRegistry) {
broadcaster(toJS(catalog.items));
}
export function startCatalogSyncToRenderer(catalog: CatalogEntityRegistry) {
return disposer( return disposer(
ipcMainOn(catalogInitChannel, () => broadcaster(toJS(catalog.items))), ipcMainOn(catalogInitChannel, () => broadcaster(toJS(catalog.items))),
reaction(() => toJS(catalog.items), (items) => { reaction(() => toJS(catalog.items), (items) => {

View File

@ -26,7 +26,7 @@ import { disposer, getAppVersion, getAppVersionFromProxyServer } from "../common
import { ipcMainOn } from "../common/ipc"; import { ipcMainOn } from "../common/ipc";
import { startUpdateChecking } from "./app-updater"; import { startUpdateChecking } from "./app-updater";
import { IpcRendererNavigationEvents } from "../renderer/navigation/events"; import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
import { pushCatalogToRenderer } from "./catalog-pusher"; import { startCatalogSyncToRenderer } from "./catalog-pusher";
import { catalogEntityRegistry } from "./catalog"; import { catalogEntityRegistry } from "./catalog";
import { HelmRepoManager } from "./helm/helm-repo-manager"; import { HelmRepoManager } from "./helm/helm-repo-manager";
import { syncGeneralEntities, syncWeblinks } from "./catalog-sources"; import { syncGeneralEntities, syncWeblinks } from "./catalog-sources";
@ -244,7 +244,7 @@ di.runSetups().then(() => {
} }
ipcMainOn(IpcRendererNavigationEvents.LOADED, async () => { ipcMainOn(IpcRendererNavigationEvents.LOADED, async () => {
onCloseCleanup.push(pushCatalogToRenderer(catalogEntityRegistry)); onCloseCleanup.push(startCatalogSyncToRenderer(catalogEntityRegistry));
const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable); const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable);