File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,18 @@ export default class ApiKeySelections {
77 twitter = '' ;
88}
99
10+ export function getStoreApiKeys ( ) {
11+ try {
12+ if ( localStorage . getItem ( 'store-api' ) ) {
13+ return JSON . parse ( localStorage . getItem ( 'store-api' ) ! ) as boolean ;
14+ }
15+ return true ;
16+ } catch {
17+ localStorage . removeItem ( 'store-api' ) ;
18+ return true ;
19+ }
20+ }
21+
1022export function getApiKeySelections ( ) {
1123 try {
1224 if ( localStorage . getItem ( 'api' ) ) {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { get, writable } from 'svelte/store';
22import { NavMode } from './components/chartUtils' ;
33import DataSet , { DataGroup } from './data/DataSet' ;
44import deriveLinkDefaults , { getDirectLinkImpl } from './deriveLinkDefaults' ;
5- import ApiKeySelections , { getApiKeySelections } from './components/dialogs/apiKeySelections' ;
5+ import { getApiKeySelections , getStoreApiKeys } from './components/dialogs/apiKeySelections' ;
66
77declare const __VERSION__ : string ;
88
@@ -18,12 +18,13 @@ export const isShowingPoints = writable(defaults.showPoints);
1818export const initialViewport = writable ( defaults . viewport ) ;
1919export const navMode = writable ( NavMode . autofit ) ;
2020
21- export const storeApiKeys = writable ( true ) ;
21+ export const storeApiKeys = writable ( getStoreApiKeys ( ) ) ;
2222storeApiKeys . subscribe ( ( val ) => {
2323 if ( ! val ) {
2424 // reset local storage if user decides not to store API keys
2525 localStorage . removeItem ( 'api' ) ;
2626 }
27+ localStorage . setItem ( 'store-api' , val . toString ( ) ) ;
2728} ) ;
2829export const apiKeySelections = writable ( getApiKeySelections ( ) ) ;
2930apiKeySelections . subscribe ( ( val ) => {
You can’t perform that action at this time.
0 commit comments