mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
1cf1037c93
* Started refactoring redux stores * Oh God huge refactor here * Sync contenst updates and nested folders * Fixed render tests * A bunch of tweaks
45 lines
920 B
JavaScript
45 lines
920 B
JavaScript
import * as db from '../common/database';
|
|
|
|
export const type = 'Settings';
|
|
export const prefix = 'set';
|
|
export function init () {
|
|
return {
|
|
showPasswords: true,
|
|
useBulkHeaderEditor: false,
|
|
followRedirects: true,
|
|
editorFontSize: 12,
|
|
editorLineWrapping: true,
|
|
httpProxy: '',
|
|
httpsProxy: '',
|
|
timeout: 0,
|
|
validateSSL: true,
|
|
forceVerticalLayout: false,
|
|
};
|
|
}
|
|
|
|
export async function all () {
|
|
const settings = await db.all(type);
|
|
if (settings.length === 0) {
|
|
return [await getOrCreate()];
|
|
} else {
|
|
return settings;
|
|
}
|
|
}
|
|
|
|
export async function create (patch = {}) {
|
|
return db.docCreate(type, patch);
|
|
}
|
|
|
|
export async function update (settings, patch) {
|
|
return db.docUpdate(settings, patch);
|
|
}
|
|
|
|
export async function getOrCreate () {
|
|
const results = await db.all(type);
|
|
if (results.length === 0) {
|
|
return await create();
|
|
} else {
|
|
return results[0];
|
|
}
|
|
}
|