mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Polishing upgrade plan UI
Summary: - Update nudge boxes content and collapsing on personal and free team site - New confirmation after upgrading from a free team site - Refactoring ProductUpgrade code, splitting plans / modals and nudges Test Plan: Manual and updated tests Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3481
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import {safeJsonParse} from 'app/common/gutil';
|
||||
import {Observable} from 'grainjs';
|
||||
|
||||
/**
|
||||
@@ -96,3 +97,14 @@ export function localStorageObs(key: string, defaultValue?: string): Observable<
|
||||
obs.addListener((val) => (val === null) ? store.removeItem(key) : store.setItem(key, val));
|
||||
return obs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to create a JSON observable whose state is stored in localStorage.
|
||||
*/
|
||||
export function localStorageJsonObs<T>(key: string, defaultValue: T): Observable<T> {
|
||||
const store = getStorage();
|
||||
const currentValue = safeJsonParse(store.getItem(key) || '', defaultValue ?? null);
|
||||
const obs = Observable.create<T>(null, currentValue);
|
||||
obs.addListener((val) => (val === null) ? store.removeItem(key) : store.setItem(key, JSON.stringify(val ?? null)));
|
||||
return obs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user