mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Improve dark mode
Summary: Enhances dark mode support for the formula editor, and adds support to the color select popup. Also fixes some bugs with dark mode. Test Plan: Tested manually. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3847
This commit is contained in:
@@ -20,18 +20,24 @@ function makePrefFunctions<P extends keyof PrefsTypes>(prefsTypeName: P) {
|
||||
*/
|
||||
function getPrefsObs(appModel: AppModel): Observable<PrefsType> {
|
||||
if (appModel.currentValidUser) {
|
||||
const prefsObs = Observable.create<PrefsType>(null, appModel.currentOrg?.[prefsTypeName] ?? {});
|
||||
let prefs: PrefsType | undefined;
|
||||
if (prefsTypeName === 'userPrefs') {
|
||||
prefs = appModel.currentValidUser.prefs;
|
||||
} else {
|
||||
prefs = appModel.currentOrg?.[prefsTypeName];
|
||||
}
|
||||
const prefsObs = Observable.create<PrefsType>(null, prefs ?? {});
|
||||
return Computed.create(null, (use) => use(prefsObs))
|
||||
.onWrite(prefs => {
|
||||
prefsObs.set(prefs);
|
||||
return appModel.api.updateOrg('current', {[prefsTypeName]: prefs});
|
||||
.onWrite(newPrefs => {
|
||||
prefsObs.set(newPrefs);
|
||||
return appModel.api.updateOrg('current', {[prefsTypeName]: newPrefs});
|
||||
});
|
||||
} else {
|
||||
const userId = appModel.currentUser?.id || 0;
|
||||
const jsonPrefsObs = localStorageObs(`${prefsTypeName}:u=${userId}`);
|
||||
return Computed.create(null, jsonPrefsObs, (use, p) => (p && JSON.parse(p) || {}) as PrefsType)
|
||||
.onWrite(prefs => {
|
||||
jsonPrefsObs.set(JSON.stringify(prefs));
|
||||
.onWrite(newPrefs => {
|
||||
jsonPrefsObs.set(JSON.stringify(newPrefs));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user