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 committed Feb 22, 2021
1 parent e9648fc commit d78d765
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 @@ -213,20 +213,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 d78d765

Please sign in to comment.