@@ -32,6 +32,10 @@ export function decodeStore(hash: string): any {
3232 */
3333export function saveStore ( store : Store ) : void {
3434 const hash = encodeStore ( store ) ;
35+ localStorage . setItem (
36+ 'playgroundShowInternals' ,
37+ store . showInternals . toString ( ) ,
38+ ) ;
3539 localStorage . setItem ( 'playgroundStore' , hash ) ;
3640 history . replaceState ( { } , '' , `#${ hash } ` ) ;
3741}
@@ -58,20 +62,29 @@ export function initStoreFromUrlOrLocalStorage(): Store {
5862 const encodedSourceFromLocal = localStorage . getItem ( 'playgroundStore' ) ;
5963 const encodedSource = encodedSourceFromUrl || encodedSourceFromLocal ;
6064
65+ // Prioritize local storage for showInternals field
66+ const showInternals =
67+ localStorage . getItem ( 'playgroundShowInternals' ) === 'true' ;
68+
6169 /**
6270 * No data in the URL and no data in the localStorage to fallback to.
6371 * Initialize with the default store.
6472 */
65- if ( ! encodedSource ) return defaultStore ;
73+ if ( ! encodedSource ) {
74+ return {
75+ ...defaultStore ,
76+ showInternals,
77+ } ;
78+ }
6679
67- const raw : any = decodeStore ( encodedSource ) ;
80+ const raw = decodeStore ( encodedSource ) ;
6881
6982 invariant ( isValidStore ( raw ) , 'Invalid Store' ) ;
7083
7184 // Make sure all properties are populated
7285 return {
7386 source : raw . source ,
7487 config : 'config' in raw ? raw . config : defaultConfig ,
75- showInternals : 'showInternals' in raw ? raw . showInternals : false ,
88+ showInternals,
7689 } ;
7790}
0 commit comments