Refactor effect handling in enrichNotificationsWithCharacterNames to improve data parsing
- Simplified the logic for processing notification effects by consolidating the JSON parsing into a single conditional check, enhancing code readability and maintainability. - Ensured consistent handling of effects regardless of their initial format, improving robustness in notification enrichment.
This commit is contained in:
@@ -5969,7 +5969,10 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
||||
// parse n.effects if present
|
||||
try {
|
||||
if (n.effects) {
|
||||
const eff = typeof n.effects === 'string' && n.effects.trim().startsWith('{') ? JSON.parse(n.effects) : n.effects;
|
||||
let eff = n.effects;
|
||||
if (typeof eff === 'string') {
|
||||
eff = JSON.parse(eff);
|
||||
}
|
||||
collectIds(eff);
|
||||
}
|
||||
} catch (err) { /* ignore */ }
|
||||
@@ -6037,7 +6040,10 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
||||
|
||||
try {
|
||||
if (n.effects) {
|
||||
const eff = typeof n.effects === 'string' && n.effects.trim().startsWith('{') ? JSON.parse(n.effects) : n.effects;
|
||||
let eff = n.effects;
|
||||
if (typeof eff === 'string') {
|
||||
eff = JSON.parse(eff);
|
||||
}
|
||||
foundId = findFirstId(eff) || foundId;
|
||||
}
|
||||
} catch (err) { /* ignore */ }
|
||||
|
||||
Reference in New Issue
Block a user