From 77fabf201897674dc22eb424722b847321cb7c9d Mon Sep 17 00:00:00 2001 From: test Date: Sun, 8 Mar 2026 21:58:56 +0800 Subject: [PATCH] fix(shared-state): clear shared Production IDs when input is cleared Fixes a bug where clearing the order number input in the extraction page did not clear the shared Production IDs in the main process. This caused the data cleanup page to continue using stale data when filtering by Production ID. Changes: - Add VALIDATION_CLEAR_SHARED_PRODUCTION_IDS IPC channel - Register handler to clear shared Production IDs by sender ID - Expose clearSharedProductionIds API in preload script - Update ExtractorPage to call clear when order numbers are empty Co-Authored-By: Claude Sonnet 4.5 --- src/main/ipc/validation-handler.ts | 11 +++++++++++ src/preload/index.ts | 2 ++ src/renderer/src/pages/ExtractorPage.tsx | 3 +++ src/shared/ipc-channels.ts | 1 + 4 files changed, 17 insertions(+) diff --git a/src/main/ipc/validation-handler.ts b/src/main/ipc/validation-handler.ts index 7cca723..f26ee2b 100644 --- a/src/main/ipc/validation-handler.ts +++ b/src/main/ipc/validation-handler.ts @@ -755,6 +755,17 @@ export function registerValidationHandlers(): void { } ) + /** + * Clear shared Production IDs + */ + ipcMain.handle( + IPC_CHANNELS.VALIDATION_CLEAR_SHARED_PRODUCTION_IDS, + async (event): Promise => { + log.info('Clearing shared Production IDs') + clearSharedProductionIds(event.sender.id) + } + ) + /** * Get cleaner data (order numbers from shared Production IDs + material codes from MaterialsToBeDeleted) * Filters materials by current user (admin sees all, regular users see only their own) diff --git a/src/preload/index.ts b/src/preload/index.ts index e7dc5f7..ffa6b55 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -140,6 +140,8 @@ const api = { invokeIpc(IPC_CHANNELS.VALIDATION_SET_SHARED_PRODUCTION_IDS, productionIds), getSharedProductionIds: (): Promise => invokeIpc(IPC_CHANNELS.VALIDATION_GET_SHARED_PRODUCTION_IDS), + clearSharedProductionIds: (): Promise => + invokeIpc(IPC_CHANNELS.VALIDATION_CLEAR_SHARED_PRODUCTION_IDS), getCleanerData: (): Promise => invokeIpc(IPC_CHANNELS.VALIDATION_GET_CLEANER_DATA) }, diff --git a/src/renderer/src/pages/ExtractorPage.tsx b/src/renderer/src/pages/ExtractorPage.tsx index c30e5b5..4ab51a1 100644 --- a/src/renderer/src/pages/ExtractorPage.tsx +++ b/src/renderer/src/pages/ExtractorPage.tsx @@ -30,6 +30,9 @@ const ExtractorPage: React.FC = () => { .map((line) => line.trim()) .filter((line) => line.length > 0) window.electron.validation.setSharedProductionIds(orderNumberList) + } else { + // Clear shared Production IDs when input is cleared + window.electron.validation.clearSharedProductionIds() } }, [orderNumbers]) diff --git a/src/shared/ipc-channels.ts b/src/shared/ipc-channels.ts index 52d085e..e6cef3d 100644 --- a/src/shared/ipc-channels.ts +++ b/src/shared/ipc-channels.ts @@ -51,6 +51,7 @@ export const IPC_CHANNELS = { VALIDATION_VALIDATE: 'validation:validate', VALIDATION_SET_SHARED_PRODUCTION_IDS: 'validation:setSharedProductionIds', VALIDATION_GET_SHARED_PRODUCTION_IDS: 'validation:getSharedProductionIds', + VALIDATION_CLEAR_SHARED_PRODUCTION_IDS: 'validation:clearSharedProductionIds', VALIDATION_GET_CLEANER_DATA: 'validation:getCleanerData', // Materials