mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 14:06:00 +00:00
fixed changing editor theme #300
This commit is contained in:
@@ -29,7 +29,11 @@ export function writableWithStorage<T>(defaultValue: T, storageName) {
|
||||
}
|
||||
|
||||
export function writableSettingsValue<T>(defaultValue: T, storageName) {
|
||||
const res = derived(useSettings(), $settings => ($settings || {})[storageName] ?? defaultValue);
|
||||
const res = derived(useSettings(), $settings => {
|
||||
const obj = $settings || {};
|
||||
// console.log('GET SETTINGS', $settings, storageName, obj[storageName]);
|
||||
return obj[storageName] ?? defaultValue;
|
||||
});
|
||||
return {
|
||||
...res,
|
||||
set: value => apiCall('config/update-settings', { [storageName]: value }),
|
||||
|
||||
@@ -189,25 +189,29 @@ async function getCore(loader, args) {
|
||||
function useCore(loader, args) {
|
||||
const { url, params, reloadTrigger, transform, onLoaded } = loader(args);
|
||||
const cacheKey = stableStringify({ url, ...params });
|
||||
let closed = false;
|
||||
let openedCount = 0;
|
||||
|
||||
return {
|
||||
subscribe: onChange => {
|
||||
async function handleReload() {
|
||||
const res = await getCore(loader, args);
|
||||
if (!closed) {
|
||||
if (openedCount > 0) {
|
||||
onChange(res);
|
||||
}
|
||||
}
|
||||
|
||||
openedCount += 1;
|
||||
handleReload();
|
||||
|
||||
if (reloadTrigger) {
|
||||
subscribeCacheChange(reloadTrigger, cacheKey, handleReload);
|
||||
return () => {
|
||||
closed = true;
|
||||
openedCount -= 1;
|
||||
unsubscribeCacheChange(reloadTrigger, cacheKey, handleReload);
|
||||
};
|
||||
} else {
|
||||
return () => {
|
||||
openedCount -= 1;
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user