From 715e4559aad591fc00788c32f651b1a7632a289f Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 2 Jul 2025 18:21:42 +0200 Subject: [PATCH] Fix saving notes for automatically categorized signatures --- frontend/src/pages/SystemView.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/SystemView.tsx b/frontend/src/pages/SystemView.tsx index e4d565d..7b49d26 100644 --- a/frontend/src/pages/SystemView.tsx +++ b/frontend/src/pages/SystemView.tsx @@ -22,6 +22,7 @@ export const SystemView = () => { } const saveSignature = async (signature: Signature): Promise => { + console.log(signature); try { // Check if signature already exists let existingRecord: SignatureRecord | null = null; @@ -34,7 +35,7 @@ export const SystemView = () => { const newScannedPercentage = parseScannedPercentage(signature.scanned); if (existingRecord) { - const updatedSignature: Pick = { + const updatedSignature: Pick = { updated: new Date().toISOString() } // Existing record has no type and our new signature has a type @@ -47,6 +48,8 @@ export const SystemView = () => { const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned); if (newScannedPercentage >= existingScannedPercentage) updatedSignature.scanned = signature.scanned; + if (!!!existingRecord.note && !!signature.note) + updatedSignature.note = signature.note; await pb.collection('signature').update(existingRecord.id, updatedSignature); console.log(`Updated signature ${signature.identifier}: ${existingScannedPercentage}% -> ${newScannedPercentage}%`); } else { @@ -57,7 +60,8 @@ export const SystemView = () => { name: signature.signame, type: signature.type, dangerous: signature.dangerous, - scanned: signature.scanned + scanned: signature.scanned, + note: signature.note }); console.log(`Created new signature ${signature.identifier} with ${newScannedPercentage}% scan`); } @@ -70,10 +74,10 @@ export const SystemView = () => { const deleteSignature = async (signatureId: string): Promise => { try { await pb.collection('signature').delete(signatureId); - + // Invalidate queries to refresh the data queryClient.invalidateQueries({ queryKey: ['signatures', system] }); - + toast({ title: "Signature Deleted", description: "The signature has been successfully deleted.", @@ -93,14 +97,14 @@ export const SystemView = () => { try { // Get the system ID for the current system const systemId = await getSystemId(system); - + console.log('Updating signature:', { identifier: updatedSignature.identifier, systemId, system, updatedSignature }); - + // Find the signature by identifier and system const existingRecord = await pb.collection('signature').getFirstListItem( `identifier='${updatedSignature.identifier}' && system='${systemId}'` @@ -132,10 +136,10 @@ export const SystemView = () => { console.log('Update data:', updateData); await pb.collection('signature').update(existingRecord.id, updateData); - + // Invalidate queries to refresh the data queryClient.invalidateQueries({ queryKey: ['signatures', system] }); - + toast({ title: "Signature Updated", description: "The signature has been successfully updated.",