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 <noreply@anthropic.com>
This commit is contained in:
test
2026-03-08 21:58:56 +08:00
parent 13187ddce1
commit 77fabf2018
4 changed files with 17 additions and 0 deletions

View File

@@ -755,6 +755,17 @@ export function registerValidationHandlers(): void {
}
)
/**
* Clear shared Production IDs
*/
ipcMain.handle(
IPC_CHANNELS.VALIDATION_CLEAR_SHARED_PRODUCTION_IDS,
async (event): Promise<void> => {
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)

View File

@@ -140,6 +140,8 @@ const api = {
invokeIpc(IPC_CHANNELS.VALIDATION_SET_SHARED_PRODUCTION_IDS, productionIds),
getSharedProductionIds: (): Promise<IpcResult> =>
invokeIpc(IPC_CHANNELS.VALIDATION_GET_SHARED_PRODUCTION_IDS),
clearSharedProductionIds: (): Promise<IpcResult> =>
invokeIpc(IPC_CHANNELS.VALIDATION_CLEAR_SHARED_PRODUCTION_IDS),
getCleanerData: (): Promise<IpcResult> => invokeIpc(IPC_CHANNELS.VALIDATION_GET_CLEANER_DATA)
},

View File

@@ -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])

View File

@@ -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