From 110cefd15a9ac673ced7872c7e42f257c22cffd0 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 16 Jun 2025 19:34:18 +0200 Subject: [PATCH] Implement pasting into wormholes by maintaining a legit system along with a wormhole system --- src/utils/wormholeStorage.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/utils/wormholeStorage.ts b/src/utils/wormholeStorage.ts index 949c3d3..e344936 100644 --- a/src/utils/wormholeStorage.ts +++ b/src/utils/wormholeStorage.ts @@ -1,7 +1,9 @@ import { System } from '@/lib/types'; import pb from '@/lib/pocketbase'; +import { SystemRecord } from '@/lib/pbtypes'; const wormholeCollection = pb.collection('wormholeSystems'); +const systemsCollection = pb.collection('system'); // Load all wormhole systems export const loadWormholeSystems = async (): Promise> => { @@ -19,9 +21,24 @@ export const saveWormholeSystem = async (system: System): Promise => { try { console.log('Saving wormhole system:', system); if (system.id) { - return await wormholeCollection.update(system.id, system); + await wormholeCollection.update(system.id, system); + const legitSystem: SystemRecord = { + id: system.id, + name: system.solarSystemName, + region: "Wormhole", + connectedTo: system.connectedSystems + } + await systemsCollection.update(system.id, legitSystem); } else { - return await wormholeCollection.create(system); + const createdWormhole = await wormholeCollection.create(system); + const legitSystem: SystemRecord = { + id: createdWormhole.id, + name: createdWormhole.solarSystemName, + region: "Wormhole", + connectedTo: createdWormhole.connectedSystems, + } + await systemsCollection.create(legitSystem); + return createdWormhole; } } catch (error) { console.error('Error saving wormhole system:', error); @@ -35,6 +52,7 @@ export const deleteWormholeSystem = async (system: System): Promise => { throw new Error('System has no ID'); } await wormholeCollection.delete(system.id); + await systemsCollection.delete(system.id); } catch (error) { console.error('Error deleting wormhole system:', error); throw error;