Skip to content

Commit

Permalink
Merge branch 'master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
UberMouse committed Jan 25, 2024
2 parents a9c252e + e8ba7db commit 2ab098f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
* **core:** xstate v5 support ([4c7a57a](https://github.com/koordinates/xstate-tree/commit/4c7a57ad5842a76aa2a33360f3a81c04eb66ca72)), closes [#58](https://github.com/koordinates/xstate-tree/issues/58)


## [4.6.1](https://github.com/koordinates/xstate-tree/compare/v4.6.0...v4.6.1) (2024-01-25)


### fix

* **routing:** flakey onloadEvent detection ([43f17c6](https://github.com/koordinates/xstate-tree/commit/43f17c67c60f566164ba7dcaa010719139183973))

# [4.6.0](https://github.com/koordinates/xstate-tree/compare/v4.5.0...v4.6.0) (2024-01-23)


Expand Down
10 changes: 0 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ export function assert(value: unknown, msg?: string): asserts value {
}
}

export function isLikelyPageLoad(): boolean {
// without performance API, we can't tell if this is a page load
if (typeof performance === "undefined") {
return false;
}

// if it's been < 5 seconds since the page was loaded, it's probably a page load
return performance.now() < 5000;
}

export function difference(a: any, b: any) {
const result: Record<any, any> = {};

Expand Down
4 changes: 2 additions & 2 deletions src/xstateTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { GetSlotNames, Slot } from "./slots";
import { GlobalEvents, AnyXstateTreeMachine, XstateTreeHistory } from "./types";
import { useConstant } from "./useConstant";
import { useService } from "./useService";
import { assertIsDefined, isLikelyPageLoad, mergeMeta, toJSON } from "./utils";
import { assertIsDefined, mergeMeta, toJSON } from "./utils";

export const emitter = new TinyEmitter();

Expand Down Expand Up @@ -449,7 +449,7 @@ export function buildRootComponent(
} = routing;
const initialMeta = {
...(routing.history.location.state?.meta ?? {}),
onloadEvent: isLikelyPageLoad(),
onloadEvent: true,
} as SharedMeta;

const queryString = getQueryString();
Expand Down

0 comments on commit 2ab098f

Please sign in to comment.