Track encounter start/end timestamps; display on card
startEncounter sets startedAt (clears endedAt on restart). endEncounter sets endedAt. snapshotOf includes both for undo/redo fidelity. expandUndo split start/end cases to restore old timestamps. Display: encounter card shows Started/Ended independently (endedAt shows even without startedAt). Undo sets null (can't delete via merge), test snap strips only startedAt/endedAt null for compare. Reviewed by pi gpt-5.5: stale endedAt on restart fixed, snap null-strip narrowed. Medium-low risk.
This commit is contained in:
@@ -29,7 +29,13 @@ function enc(ps) {
|
||||
return { name:'t', participants:ps, isStarted:false, isPaused:false,
|
||||
round:0, currentTurnParticipantId:null, turnOrderIds:[] };
|
||||
}
|
||||
const snap = (e) => JSON.parse(JSON.stringify(e));
|
||||
const snap = (e) => {
|
||||
const o = JSON.parse(JSON.stringify(e));
|
||||
// normalize nullable timestamp fields: null = absent (undo clears via null)
|
||||
if (o.startedAt === null) delete o.startedAt;
|
||||
if (o.endedAt === null) delete o.endedAt;
|
||||
return o;
|
||||
};
|
||||
|
||||
describe('undo + redo roundtrip', () => {
|
||||
test('startEncounter', async () => {
|
||||
|
||||
Reference in New Issue
Block a user