Fraser commited on
Commit
007132e
·
1 Parent(s): 5730391
src/lib/components/Pages/Encounters.svelte CHANGED
@@ -346,25 +346,40 @@
346
  nextPosition = 5;
347
  }
348
 
 
 
 
 
 
 
 
349
  // Update the captured piclet to be in roster
350
- await db.picletInstances.update(capturedPiclet.id, {
351
  caught: true,
352
  caughtAt: new Date(),
353
  isInRoster: true,
354
  rosterPosition: nextPosition
355
  });
356
 
 
357
  console.log(`Added captured Piclet ${capturedPiclet.nickname} to roster position ${nextPosition}`);
358
 
359
  // Get the updated piclet instance and show detail page
 
360
  const updatedPiclet = await db.picletInstances.get(capturedPiclet.id);
 
 
361
  if (updatedPiclet) {
362
  console.log('Setting newlyCaughtPiclet and showing detail page:', updatedPiclet.nickname);
363
  newlyCaughtPiclet = updatedPiclet;
364
  showNewlyCaught = true;
365
  console.log('showNewlyCaught is now:', showNewlyCaught);
366
  } else {
367
- console.error('Could not retrieve updated piclet from database');
 
 
 
 
368
  }
369
  } catch (error) {
370
  console.error('Error adding captured Piclet to roster:', error);
 
346
  nextPosition = 5;
347
  }
348
 
349
+ console.log('About to update captured Piclet in database:', {
350
+ id: capturedPiclet.id,
351
+ nickname: capturedPiclet.nickname,
352
+ currentCaught: capturedPiclet.caught,
353
+ currentInRoster: capturedPiclet.isInRoster
354
+ });
355
+
356
  // Update the captured piclet to be in roster
357
+ const updateResult = await db.picletInstances.update(capturedPiclet.id, {
358
  caught: true,
359
  caughtAt: new Date(),
360
  isInRoster: true,
361
  rosterPosition: nextPosition
362
  });
363
 
364
+ console.log('Database update result:', updateResult);
365
  console.log(`Added captured Piclet ${capturedPiclet.nickname} to roster position ${nextPosition}`);
366
 
367
  // Get the updated piclet instance and show detail page
368
+ console.log('Attempting to retrieve updated piclet with ID:', capturedPiclet.id);
369
  const updatedPiclet = await db.picletInstances.get(capturedPiclet.id);
370
+ console.log('Retrieved piclet from database:', updatedPiclet);
371
+
372
  if (updatedPiclet) {
373
  console.log('Setting newlyCaughtPiclet and showing detail page:', updatedPiclet.nickname);
374
  newlyCaughtPiclet = updatedPiclet;
375
  showNewlyCaught = true;
376
  console.log('showNewlyCaught is now:', showNewlyCaught);
377
  } else {
378
+ console.error('Could not retrieve updated piclet from database - ID:', capturedPiclet.id);
379
+ // Let's try to show the original piclet data as fallback
380
+ console.log('Trying fallback with original piclet data');
381
+ newlyCaughtPiclet = capturedPiclet;
382
+ showNewlyCaught = true;
383
  }
384
  } catch (error) {
385
  console.error('Error adding captured Piclet to roster:', error);