@shoppexio/storefront-react 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ - Favorites follow the account session without a reload. Signing in on the
6
+ account page reloads the favorites store, so the hearts on cards and the
7
+ product page work at once instead of sending the buyer back to Account.
8
+ Signing out reloads it too, which clears the previous buyer's saved set
9
+ instead of leaving it on the page for whoever uses the browser next.
10
+ (`announceCustomerSessionChange()`, `signOutEndedSession()`.)
11
+
3
12
  ## 0.2.0
4
13
 
5
14
  Breaking:
package/dist/account.js CHANGED
@@ -12507,6 +12507,12 @@ function remainingSearch(search) {
12507
12507
  const query = kept.toString();
12508
12508
  return query ? `?${query}` : "";
12509
12509
  }
12510
+ function announceCustomerSessionChange() {
12511
+ notifyFavoritesChanged();
12512
+ }
12513
+ function signOutEndedSession(result) {
12514
+ return result.success || result.status !== void 0;
12515
+ }
12510
12516
  function AccountPage({ frame: Frame, notFound }) {
12511
12517
  const location = useLocation();
12512
12518
  const search = new URLSearchParams(location.search);
@@ -12545,11 +12551,12 @@ function AccountPage({ frame: Frame, notFound }) {
12545
12551
  setSignOutError(null);
12546
12552
  const result = await callCustomerApi((sdk) => sdk.logout());
12547
12553
  setSigningOut(false);
12548
- if (!result.success && result.status === void 0) {
12554
+ if (!signOutEndedSession(result)) {
12549
12555
  setSignOutError(result.message?.trim() || t("account.signOutFailed"));
12550
12556
  return;
12551
12557
  }
12552
12558
  setSession({ status: "signed-out" });
12559
+ announceCustomerSessionChange();
12553
12560
  };
12554
12561
  if (canonical !== null) return /* @__PURE__ */ jsx15(Navigate, { to: `${canonical}${remainingSearch(search)}`, replace: true });
12555
12562
  if (view.kind === "unknown-tab") return /* @__PURE__ */ jsx15(Fragment3, { children: notFound });
@@ -12585,6 +12592,7 @@ function AccountPage({ frame: Frame, notFound }) {
12585
12592
  onSignedIn: () => {
12586
12593
  setPrefill(spendSignInPrefill());
12587
12594
  setSession({ status: "signed-in" });
12595
+ announceCustomerSessionChange();
12588
12596
  }
12589
12597
  }
12590
12598
  ) : null,