From 65f5521c7407796f49aaf34cdcdc85fc78072921 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 29 Nov 2025 02:22:03 -0800 Subject: [PATCH] fix: use swap API endpoints for drag-and-drop rearrangement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handleSwap function was calling move methods (moveWeapon, moveCharacter, moveSummon) which validate that target positions are empty. This caused 422 errors when dragging items to swap positions. Switch to using swap methods (swapWeapons, swapCharacters, swapSummons) which perform atomic swaps in a transaction and bypass position validation, allowing items to correctly swap positions. Also remove unreachable throw statement after return. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/lib/components/party/Party.svelte | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/lib/components/party/Party.svelte b/src/lib/components/party/Party.svelte index 1998be11..08482f71 100644 --- a/src/lib/components/party/Party.svelte +++ b/src/lib/components/party/Party.svelte @@ -127,25 +127,37 @@ throw new Error('Invalid swap operation - missing items') } - // Call appropriate grid service method based on type + // Call appropriate swap method based on type if (source.type === 'weapon') { - await gridService.moveWeapon(party.id, source.itemId, target.position, editKey || undefined, { - shortcode: party.shortcode - }) - } else if (source.type === 'character') { - await gridService.moveCharacter( + await gridService.swapWeapons( party.id, source.itemId, - target.position, + target.itemId, + editKey || undefined, + { + shortcode: party.shortcode + } + ) + } else if (source.type === 'character') { + await gridService.swapCharacters( + party.id, + source.itemId, + target.itemId, editKey || undefined, { shortcode: party.shortcode } ) } else if (source.type === 'summon') { - await gridService.moveSummon(party.id, source.itemId, target.position, editKey || undefined, { - shortcode: party.shortcode - }) + await gridService.swapSummons( + party.id, + source.itemId, + target.itemId, + editKey || undefined, + { + shortcode: party.shortcode + } + ) } else { throw new Error(`Unknown item type: ${source.type}`) } @@ -154,8 +166,6 @@ partyService.clearPartyCache(party.shortcode) const updated = await partyService.getByShortcode(party.shortcode) return updated - - throw new Error(`Unknown item type: ${source.type}`) } async function handleMove(source: any, target: any): Promise {