Implementing an 'account' dialog (WIP)

This commit is contained in:
vdv committed 2022-12-25 16:30:47 +01:00
1 parent 0e2ffb0cf2
commit a36c8a28a4
12 files changed
+235 -22

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import { getFamily, put } from './lib';
import getUri from '../lib/ids';
export const getAccounts = async () => {
return await getFamily('account', {}, true);
};
export const putAccount = async (name: string, account: any) => {
const uri = getUri('account', name);
return await put(uri, 'account', (_: any) => account, {}, true);
};
+3 -2
View File
@@ -36,8 +36,9 @@ export const put = async (
}
};
export const getFamily = async (key: string, options: any = {}) => {
return await db.allDocs({
export const getFamily = async (key: string, options: any = {}, local: boolean = false) => {
const targetDb = local ? localDb : db;
return await targetDb.allDocs({
startkey: key,
endkey: key + '\ufff0',
...options,
+14
View File
@@ -0,0 +1,14 @@
import { get, put } from './lib';
export const getSettings = async () => {
try {
return await get('settings', true);
} catch (err) {
console.error({ caller: 'getSettings', err });
return undefined;
}
};
export const putSettings = async (settings: any) => {
return await put('settings', 'settings', (_: any) => settings, {}, true);
};