Skip to content

Commit 41202b2

Browse files
refactor
1 parent 609d4e1 commit 41202b2

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

extensions/plugin-history-sync/src/historySyncPlugin.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,12 @@ export function historySyncPlugin<
337337
],
338338
]);
339339
} else {
340+
//@TODO: Initial push must be marked as skipEnterActiveState: true
340341
initialSetupProcess = new SerialNavigationProcess([
341-
...defaultHistory.map((historyEntry, index) => () => {
342-
let isFirstPush = true;
343-
342+
...defaultHistory.map((historyEntry) => () => {
344343
return historyEntryToEvents(historyEntry).map((event) => {
345344
if (event.name !== "Pushed") return event;
346-
const skipEnterActiveState = index === 0 && isFirstPush;
347345

348-
isFirstPush = false;
349346
activityActivationMonitors.push(
350347
new DefaultHistoryActivityActivationMonitor(
351348
event.activityId,
@@ -355,7 +352,6 @@ export function historySyncPlugin<
355352

356353
return {
357354
...event,
358-
skipEnterActiveState,
359355
};
360356
});
361357
}),
@@ -364,13 +360,24 @@ export function historySyncPlugin<
364360
}
365361

366362
const now = Date.now();
367-
368-
return initialSetupProcess
363+
const initialEvents = initialSetupProcess
369364
.captureNavigationOpportunity(null)
370365
.map((event, index, array) => ({
371366
...event,
372367
eventDate: now - (array.length - index),
373368
}));
369+
const firstPushEvent = initialEvents.find(
370+
(event) => event.name === "Pushed",
371+
);
372+
373+
return initialEvents.map((event) => {
374+
if (event.id !== firstPushEvent?.id) return event;
375+
376+
return {
377+
...event,
378+
skipEnterActiveState: true,
379+
};
380+
});
374381
},
375382
onInit({ actions: { getStack, dispatchEvent, push, stepPush } }) {
376383
const stack = getStack();

0 commit comments

Comments
 (0)