mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-04-20 01:01:03 +00:00
24 lines
537 B
JavaScript
24 lines
537 B
JavaScript
|
import { writable } from 'svelte/store';
|
||
|
import { Settings, UpdateSettings } from '../../../wailsjs/go/app/App';
|
||
|
|
||
|
const { set, subscribe } = writable({});
|
||
|
let skipUpdate = true;
|
||
|
|
||
|
async function reload() {
|
||
|
const newSettings = await Settings();
|
||
|
set(newSettings);
|
||
|
return newSettings;
|
||
|
}
|
||
|
|
||
|
reload();
|
||
|
subscribe(newSettings => {
|
||
|
if (skipUpdate) {
|
||
|
skipUpdate = false;
|
||
|
return;
|
||
|
}
|
||
|
UpdateSettings(JSON.stringify(newSettings || {}));
|
||
|
});
|
||
|
|
||
|
const applicationSettings = { reload, set, subscribe };
|
||
|
export default applicationSettings;
|