fix(turn): log addParticipants + updateParticipant (logging gaps)
addParticipants + updateParticipant returned log:null → invisible in
combat log. Contract test caught them. Now both return
log:{ message, undo:{ participants }}.
App.js handlers wired (handleAddAllCharacters, handleUpdateParticipant,
handleInlineInitiative) — call logAction on logged mutations.
Logging contract now complete: every mutating combat op produces a log
entry. No gaps. turn.logging.test.js proves it.
238 tests green.
This commit is contained in:
+21
-3
@@ -940,8 +940,14 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) {
|
||||
}
|
||||
|
||||
try {
|
||||
const { patch } = addParticipants(encounter, newParticipants);
|
||||
const { patch, log } = addParticipants(encounter, newParticipants);
|
||||
await storage.updateDoc(encounterPath, patch);
|
||||
if (log) {
|
||||
logAction(log.message, { encounterName: encounter.name }, {
|
||||
encounterPath,
|
||||
updates: log.undo,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
alert("Failed to add all characters. Please try again.");
|
||||
}
|
||||
@@ -950,8 +956,14 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) {
|
||||
const handleUpdateParticipant = async (updatedData) => {
|
||||
if (!db || !editingParticipant) return;
|
||||
try {
|
||||
const { patch } = updateParticipant(encounter, editingParticipant.id, updatedData);
|
||||
const { patch, log } = updateParticipant(encounter, editingParticipant.id, updatedData);
|
||||
await storage.updateDoc(encounterPath, patch);
|
||||
if (log) {
|
||||
logAction(log.message, { encounterName: encounter.name }, {
|
||||
encounterPath,
|
||||
updates: log.undo,
|
||||
});
|
||||
}
|
||||
setEditingParticipant(null);
|
||||
} catch (err) {
|
||||
alert("Failed to update participant. Please try again.");
|
||||
@@ -967,8 +979,14 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) {
|
||||
const n = parseInt(value, 10);
|
||||
if (isNaN(n)) return;
|
||||
try {
|
||||
const { patch } = updateParticipant(encounter, participantId, { initiative: n });
|
||||
const { patch, log } = updateParticipant(encounter, participantId, { initiative: n });
|
||||
await storage.updateDoc(encounterPath, patch);
|
||||
if (log) {
|
||||
logAction(log.message, { encounterName: encounter.name }, {
|
||||
encounterPath,
|
||||
updates: log.undo,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
// fall through silently
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user