Compare commits

..

No commits in common. "9badc6e8930dd3a2b2c2bc14ffefc43cbcfea521" and "46bce99fd6212079f3d6fd2d212d04491504760b" have entirely different histories.

View file

@ -57,7 +57,7 @@ export default abstract class SettingHelper {
} }
let processedValue = rawValue; let processedValue = rawValue;
if (typeof settingType.type === "string" && settingType.type.includes("/crypt") && processedValue != "") { if (typeof settingType.type === "string" && settingType.type.includes("/crypt")) {
processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue); processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue);
} }
@ -76,7 +76,7 @@ export default abstract class SettingHelper {
* @param value The value to set * @param value The value to set
*/ */
public static async setSetting<K extends SettingString>(key: K, value: SettingValueMapping[K]): Promise<void> { public static async setSetting<K extends SettingString>(key: K, value: SettingValueMapping[K]): Promise<void> {
if (value === undefined || value === null || value == "") { if (value === undefined || value === null) {
if (key != "mail.password") this.resetSetting(key); if (key != "mail.password") this.resetSetting(key);
return; return;
} }
@ -93,7 +93,7 @@ export default abstract class SettingHelper {
newValue = CodingHelper.encrypt(APPLICATION_SECRET, stringValue); newValue = CodingHelper.encrypt(APPLICATION_SECRET, stringValue);
} }
this.settings[key] = newValue; this.settings[key] = stringValue;
const [topic, settingKey] = key.split(".") as [SettingTopic, string]; const [topic, settingKey] = key.split(".") as [SettingTopic, string];
await SettingCommandHandler.create({ await SettingCommandHandler.create({
@ -265,7 +265,9 @@ export default abstract class SettingHelper {
* @param oldValue The old value * @param oldValue The old value
*/ */
private static notifyListeners(key: SettingString, newValue: any, oldValue: any): void { private static notifyListeners(key: SettingString, newValue: any, oldValue: any): void {
const callbacks = this.listeners.get(key) ?? []; if (!this.listeners.has(key)) return;
const callbacks = this.listeners.get(key)!;
for (const callback of callbacks) { for (const callback of callbacks) {
try { try {
callback(newValue, oldValue); callback(newValue, oldValue);
@ -274,7 +276,7 @@ export default abstract class SettingHelper {
} }
} }
const topicCallbacks = this.topicListeners.get(key.split(".")[0] as SettingTopic) ?? []; const topicCallbacks = this.topicListeners.get(key.split(".")[0] as SettingTopic)!;
for (const callback of topicCallbacks) { for (const callback of topicCallbacks) {
try { try {
callback(); callback();