simplify settings

This commit is contained in:
Jan Prochazka
2021-04-18 10:40:33 +02:00
parent e97388e14b
commit cacd6ae849
5 changed files with 37 additions and 19 deletions

View File

@@ -43,14 +43,12 @@ export const activeTab = derived([openedTabs], ([$openedTabs]) => $openedTabs.fi
export const recentDatabases = writableWithStorage([], 'recentDatabases');
export const commandsSettings = derived(useSettings(), (config: any) => (config || {}).commands || {});
export const allResultsInOneTabDefault = writableWithStorage(false, 'allResultsInOneTabDefault');
export const commandsCustomized = derived(
[commands, commandsSettings],
([$commands, $commandsSettings]) =>
_.mapValues($commands, (v, k) => ({
// @ts-ignore
...v,
...$commandsSettings[k],
}))
export const commandsCustomized = derived([commands, commandsSettings], ([$commands, $commandsSettings]) =>
_.mapValues($commands, (v, k) => ({
// @ts-ignore
...v,
...$commandsSettings[k],
}))
);
export const visibleToolbar = writableWithStorage(1, 'visibleToolbar');
@@ -137,3 +135,10 @@ currentDatabase.subscribe(value => {
invalidateCommands();
});
export const getCurrentDatabase = () => currentDatabaseValue;
let currentSettingsValue = null;
useSettings().subscribe(value => {
currentSettingsValue = value;
invalidateCommands();
});
export const getCurrentSettings = () => currentSettingsValue || {};