Skip to content

Commit 7cfdb9f

Browse files
committed
extracted storage key
1 parent ed0de11 commit 7cfdb9f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Category} from "./category";
22

33
const DATA_TYPE_MAP: string = 'Map';
4+
const STORAGE_KEY = 'sankey-config-v2'; // increase this version number if config is not backwards compatible
45

56
export type Config = {
67
scalingFactor: number;
@@ -13,11 +14,11 @@ let defaultConfig: Config = {scalingFactor: 1, threshold: 0, currency: 'EUR', ca
1314
export default defaultConfig;
1415

1516
export function save(config: Config) {
16-
localStorage.setItem('config', JSON.stringify(config, mapReplacer));
17+
localStorage.setItem(STORAGE_KEY, JSON.stringify(config, mapReplacer));
1718
}
1819

1920
export function load(): Config|null {
20-
const jsonConfig = localStorage.getItem('config');
21+
const jsonConfig = localStorage.getItem(STORAGE_KEY);
2122
return jsonConfig === null ? null : JSON.parse(jsonConfig, mapReviver);
2223
}
2324

0 commit comments

Comments
 (0)