I have a pretty straightforward store using SettingsManager but I am getting an unhandled promise rejection saying the key does not exist
import { SettingsManager } from 'tauri-settings';
import { writable } from 'svelte/store';
type SettingsSchema = {
rootFolder: string;
};
const settingsManager = new SettingsManager<SettingsSchema>(
{
rootFolder: ''
},
{ fileName: 'rootfolder.json' }
);
const store = writable(
{
rootFolder: ''
},
() => {
settingsManager.initialize().then(async () => {
console.log('Setting Manager initialized');
/* Error thrown on the next line */
const rootFolderVal = await settingsManager.get('rootFolder');
store.set({ rootFolder: rootFolderVal });
});
}
);
const setRootFolder = async (value: string) => {
await settingsManager.set('rootFolder', value);
store.update((s) => {
s['rootFolder'] = value;
return s;
});
};
export default {
subscribe: store.subscribe,
setRootFolder
};
I thought that initializing the SettingsManager instance would make it so the key exists.
I worry this is a problem with my tauri app not being able to write to disk, but my tauri.conf.json has
"tauri": {
"allowlist": {
...
"fs": {
"all": true,
"scope": ["**", "$APPCONFIG", "$APPCONFIG/*"]
},
...
"path": {
"all": true
},
...
},