You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/12/20 21:03:13 UTC

[GitHub] [superset] ktmud commented on a change in pull request #17832: chore: Refactor localstorage into typesafe version

ktmud commented on a change in pull request #17832:
URL: https://github.com/apache/superset/pull/17832#discussion_r772666321



##########
File path: superset-frontend/src/views/CRUD/chart/ChartList.tsx
##########
@@ -164,7 +164,8 @@ function ChartList(props: ChartListProps) {
   const [preparingExport, setPreparingExport] = useState<boolean>(false);
 
   const { userId } = props.user;
-  const userKey = getFromLocalStorage(userId?.toString(), null);
+  // TODO: Fix usage of localStorage keying on the user id
+  const userKey = dangerouslyGetItemDoNotUse(userId?.toString(), null);

Review comment:
       I think `userKey` may actually be `userProfile` or `userSettings`. We can also do type coercing to avoid calling the private dangerous functions:
   
   ```ts
   const userProfile = getItem(String(userId || '') as "FIXME_user_profile_by_user_id", null);
   
   type LocalStorageValues {
     // it's a bad practice to use the raw user id as storage keys
     // we should at least prefix them.
     FIXME_user_profile_by_user_id: {
       thumbnails: boolean;
     }
   }
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org