Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
louneskmt authored Nov 7, 2020
1 parent c4e7b28 commit bc238db
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions logic/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,23 @@ async function getSettings() {

async function updateSetting(setting, value) {
try {
const user = await diskLogic.readUserFile();
const { settings = {} } = user;

if(setting) {
if(value) settings[setting] = value;
else delete settings[setting];
const settings = await getSettings();

if(!setting) return settings;

if(typeof value !== undefined) {
settings[setting] = value;
} else {
delete settings[setting];
}


const user = await diskLogic.readUserFile();
user.settings = settings;
await diskLogic.writeUserFile(user);

return user.settings;
return settings;
} catch (error) {
throw new NodeError(`Unable to update ${setting || 'setting'}`);
throw new NodeError(`Unable to update setting`);
}
};

Expand Down

0 comments on commit bc238db

Please sign in to comment.