Add canUseLocalStorage guard to other localStorage usages in the repository

Context

In !226142 (merged) (Add age indicator toggle to blame preferences dropdown), the canUseLocalStorage utility was used to guard localStorage access. This utility checks if localStorage is actually available and functional in the browser before calling localStorage.getItem/setItem.

Scenarios where localStorage may be unavailable:

  • Private/incognito mode in some browsers
  • User disabled storage via browser settings
  • Storage quota exceeded
  • SSR/non-browser environments

Without this guard, the code would throw runtime errors if localStorage is unavailable. We have seen related Sentry errors around localStorage not being found.

Proposal

As suggested by @jerasmus, we should add the canUseLocalStorage guard to other areas in the repo where we use localStorage, such as:

  • File Tree Browser (FTB)
  • Audit other localStorage usages in the repository and add the guard where missing

References

Edited by 🤖 GitLab Bot 🤖