review comments for storage

This commit is contained in:
Jonathan Rainville 2018-10-16 09:43:11 -04:00 committed by Pascal Precht
parent 0b16b028b4
commit 5e1d60882d
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D

View File

@ -1,18 +1,18 @@
export function postCurrentFile(file) {
return new Promise(function(resolve) {
return new Promise(resolve => {
localStorage.setItem('currentFile', JSON.stringify(file));
resolve({response: {data: file}});
});
}
export function fetchCurrentFile() {
return new Promise(function(resolve) {
return new Promise(resolve => {
resolve({response: {data: JSON.parse(localStorage.getItem('currentFile'))}});
});
}
export function deleteCurrentFile() {
return new Promise(function(resolve) {
return new Promise(resolve => {
localStorage.removeItem('currentFile');
resolve({});
});
@ -20,35 +20,33 @@ export function deleteCurrentFile() {
export function saveCredentials({token, host}) {
const credentials = {token, host};
return new Promise(function(resolve) {
return new Promise(resolve => {
localStorage.setItem('credentials', JSON.stringify(credentials));
resolve({response: {data: credentials}});
});
}
export function fetchCredentials() {
return new Promise(function(resolve) {
return new Promise(resolve => {
const credentials = localStorage.getItem('credentials');
resolve({response: {data: JSON.parse(credentials)}});
});
}
export function logout() {
return new Promise(function(resolve) {
return new Promise(resolve => {
localStorage.clear();
resolve({response: true});
});
}
export function changeTheme({theme}) {
return new Promise(function(resolve) {
return new Promise(resolve => {
localStorage.setItem('theme', theme);
resolve({response: {data: theme}});
});
}
export function fetchTheme() {
return new Promise(function(resolve) {
resolve({response: {data: localStorage.getItem('theme')}});
});
return new Promise(resolve => resolve({response: {data: localStorage.getItem('theme')}}));
}