Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Local Storage usage in Blocks doesn't react to changes in other windows. #11309

Open
senadir opened this issue Oct 18, 2023 · 0 comments
Open
Labels
block: mini-cart Issues related to the Mini-Cart block. team: Rubik type: bug The issue/PR concerns a confirmed bug. type: technical debt This issue/PR represents/solves the technical debt of the project.

Comments

@senadir
Copy link
Member

senadir commented Oct 18, 2023

We use Local Storage somehow in Cart/Checkout/Mini Cart, mainly for mini cart totals, and nonces and other info, however, that local storage doesn't react to changes coming from other windows, meaning you can end up with a stale data in a window that wouldn't work and would cause your requests to fail or totals to not be updated.

Solution

  • First, unify usage of local storage to the useLocalStorageState hook instead of individual calls here and there.
    - Add event reaction for the storage event so that memory copies of storage data is updated if local storage is updated in another window.
@senadir senadir added type: bug The issue/PR concerns a confirmed bug. type: technical debt This issue/PR represents/solves the technical debt of the project. labels Oct 18, 2023
@ralucaStan ralucaStan added team: Rubik block: mini-cart Issues related to the Mini-Cart block. and removed team: Kirigami & Origami labels Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: mini-cart Issues related to the Mini-Cart block. team: Rubik type: bug The issue/PR concerns a confirmed bug. type: technical debt This issue/PR represents/solves the technical debt of the project.
Projects
None yet
Development

No branches or pull requests

3 participants