Gitea Actions Runner Test / test-job (push) Successful in 0s
CI / check (push) Successful in 29s
CI / tests-integration (push) Failing after 1m43s
CI / tests-unit (push) Successful in 1m47s
CI / tests-ui (push) Successful in 2m33s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
The live catalog store only covered part of the import surface. A durable job settled, a sync queue drained, a .nitro upload or a clone run left the Studio rail and the stats bar showing pre-import numbers until the page was reloaded, and the Catalog Manager kept a second tree that never saw writes made elsewhere in the session. Every one of those paths now pulls the tree again, and the refresh carries the totals with it: importing writes catalog rows server-side, so the counts the store holds were stale for the rest of the session. - refreshCatalogTree shares one request between concurrent callers and queues a single follow-up read when a write lands mid-flight, so a burst of edits costs at most one extra read. - useFurnitureJobs treats its first payload as a baseline, so a page load no longer replays every past import as "just settled", and hands the settled jobs to the callback. - The Catalog Manager pushes its own mutations into the store and re-reads its active tab when the store changes. - The 30s unstable_cache on the admin totals is now tagged and invalidated from every catalog write, including the import worker, so it no longer survives an import even across a hard reload. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
"use server";
|
|
|
|
import { z } from "zod";
|
|
import { invalidateCatalogTotals } from "@/features/catalog/server/catalog-totals";
|
|
import { db, WebsiteSetting } from "@/lib/db";
|
|
import { PERMS } from "@/lib/permissions";
|
|
import { adminAction } from "@/lib/safe-action";
|
|
import { actionOk } from "@/lib/safe-action-shared";
|
|
import { withCatalogExport } from "@/lib/services/catalog-git-queue";
|
|
import { deleteImportedItem } from "@/lib/services/furni-import";
|
|
import { siteSettings } from "@/lib/services/site-settings";
|
|
|
|
const deleteSchema = z.object({ classname: z.string().trim().min(1) });
|
|
|
|
export const deleteImportedFurni = adminAction(
|
|
{ permission: PERMS.ASSETS_IMPORT, schema: deleteSchema },
|
|
async (ctx) => {
|
|
const result = (await withCatalogExport(() =>
|
|
deleteImportedItem(ctx.data.classname),
|
|
)) as unknown as Record<string, unknown>;
|
|
// Deleting an imported item can remove its offer and category page.
|
|
invalidateCatalogTotals();
|
|
return actionOk(result);
|
|
},
|
|
);
|
|
|
|
const translateToggleSchema = z.object({ enabled: z.boolean() });
|
|
|
|
/** Persist the global "translate furniture names" setting from the studio. */
|
|
export const setFurnidataTranslateEnabled = adminAction(
|
|
{ permission: PERMS.ASSETS_IMPORT, schema: translateToggleSchema },
|
|
async (ctx) => {
|
|
const value = ctx.data.enabled ? "1" : "0";
|
|
await db
|
|
.insert(WebsiteSetting)
|
|
.values({ key: "furnidata_translate_enabled", value })
|
|
.onDuplicateKeyUpdate({ set: { value } });
|
|
await siteSettings.reload();
|
|
return actionOk({ enabled: ctx.data.enabled });
|
|
},
|
|
);
|