Two workspaces overwrite each other's saved card arrangement


Topic: Two workspaces overwrite each other's saved card arrangement

tinyPatchLab asked a week ago

The same user can switch between two workspaces with different dashboard cards. Each workspace restores a saved arrangement, but visiting the other one replaces it. We store the array under a single dashboardOrder key in localStorage.

Is it enough to include the workspace ID in the key? We also allow signing out and signing into another account in the same browser, so that person's layout should remain separate.


Igor Przybysz staff pro premium priority answered 7 days ago

Scope the storage key to both the signed-in user's stable ID and the workspace's stable ID. localStorage belongs to the origin and browser profile, not to your application's current account, so a single dashboardOrder key is shared by these views.

When restoring, validate the stored array against that workspace's available card IDs and append any newly introduced cards. Treat this as layout preference data; it should not determine access to the cards or store authentication credentials.

const orderKey = `dashboardOrder:${userId}:${workspaceId}`;
localStorage.setItem(orderKey, JSON.stringify(cardOrder));

https://mdbootstrap.com/docs/standard/plugins/drag-and-drop/


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 9.3.0
  • Device: Laptop
  • Browser: Chrome
  • OS: macOS
  • Provided sample code: No
  • Provided link: No