2016-11-09 04:26:49 +00:00
|
|
|
import * as db from '../database';
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export const type = 'Settings';
|
|
|
|
export const prefix = 'set';
|
|
|
|
export function init () {
|
2016-11-10 01:15:27 +00:00
|
|
|
return {
|
2016-10-21 17:20:36 +00:00
|
|
|
showPasswords: false,
|
2016-10-02 20:57:00 +00:00
|
|
|
useBulkHeaderEditor: false,
|
2016-10-26 17:49:49 +00:00
|
|
|
followRedirects: true,
|
2016-10-02 20:57:00 +00:00
|
|
|
editorFontSize: 12,
|
|
|
|
editorLineWrapping: true,
|
|
|
|
httpProxy: '',
|
|
|
|
httpsProxy: '',
|
|
|
|
timeout: 0,
|
2016-10-21 17:20:36 +00:00
|
|
|
validateSSL: true,
|
|
|
|
optSyncBeta: false,
|
2016-10-26 20:19:18 +00:00
|
|
|
forceVerticalLayout: false,
|
2016-11-10 01:15:27 +00:00
|
|
|
};
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function create (patch = {}) {
|
|
|
|
return db.docCreate(type, patch);
|
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function update (settings, patch) {
|
2016-09-21 20:32:45 +00:00
|
|
|
return db.docUpdate(settings, patch);
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function getOrCreate () {
|
|
|
|
const results = await db.all(type);
|
|
|
|
if (results.length === 0) {
|
|
|
|
return await create();
|
|
|
|
} else {
|
|
|
|
return results[0];
|
|
|
|
}
|
|
|
|
}
|