nodebb-plugin-equipment-calendar 9.0.4 → 9.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library.js +11 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
package/library.js
CHANGED
|
@@ -132,6 +132,7 @@ const { v4: uuidv4 } = require('uuid');
|
|
|
132
132
|
const crypto = require('crypto');
|
|
133
133
|
|
|
134
134
|
const plugin = {};
|
|
135
|
+
const SETTINGS_DB_KEY = 'equipmentCalendar:settings';
|
|
135
136
|
const SETTINGS_KEY = 'equipmentCalendar';
|
|
136
137
|
|
|
137
138
|
const DEFAULT_SETTINGS = {
|
|
@@ -407,8 +408,16 @@ async function getActiveItems() {
|
|
|
407
408
|
}
|
|
408
409
|
|
|
409
410
|
async function getSettings() {
|
|
410
|
-
const
|
|
411
|
-
|
|
411
|
+
const defaults = DEFAULT_SETTINGS;
|
|
412
|
+
try {
|
|
413
|
+
const saved = await db.getObject(SETTINGS_DB_KEY);
|
|
414
|
+
const merged = Object.assign({}, defaults, saved || {});
|
|
415
|
+
// normalize numbers
|
|
416
|
+
merged.paymentTimeoutMinutes = parseInt(merged.paymentTimeoutMinutes, 10) || defaults.paymentTimeoutMinutes;
|
|
417
|
+
return merged;
|
|
418
|
+
} catch (e) {
|
|
419
|
+
return Object.assign({}, defaults);
|
|
420
|
+
}
|
|
412
421
|
}
|
|
413
422
|
|
|
414
423
|
// --- Data layer ---
|
package/package.json
CHANGED