translation: asyncify
This commit is contained in:
+9
-22
@@ -698,34 +698,21 @@ async function setLicenseKey(licenseKey) {
|
||||
notifyChange(exports.LICENSE_KEY, licenseKey);
|
||||
}
|
||||
|
||||
function getLanguage(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
settingsdb.get(exports.LANGUAGE_KEY, function (error, value) {
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return callback(null, gDefaults[exports.LANGUAGE_KEY]);
|
||||
if (error) return callback(error);
|
||||
|
||||
callback(null, value);
|
||||
});
|
||||
async function getLanguage() {
|
||||
const value = await get(exports.LANGUAGE_KEY);
|
||||
if (value === null) return gDefaults[exports.LANGUAGE_KEY];
|
||||
return value;
|
||||
}
|
||||
|
||||
function setLanguage(language, callback) {
|
||||
async function setLanguage(language) {
|
||||
assert.strictEqual(typeof language, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
translation.getLanguages(function (error, languages) {
|
||||
if (error) return callback(error);
|
||||
const languages = await translation.getLanguages();
|
||||
|
||||
if (languages.indexOf(language) === -1) return callback(new BoxError(BoxError.NOT_FOUND));
|
||||
if (languages.indexOf(language) === -1) throw new BoxError(BoxError.NOT_FOUND, 'Language not found');
|
||||
|
||||
settingsdb.set(exports.LANGUAGE_KEY, language, function (error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
notifyChange(exports.LANGUAGE_KEY, language);
|
||||
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
await set(exports.LANGUAGE_KEY, language);
|
||||
notifyChange(exports.LANGUAGE_KEY, language);
|
||||
}
|
||||
|
||||
async function getCloudronId() {
|
||||
|
||||
Reference in New Issue
Block a user