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
|
// parse n.effects if present
|
||||||
try {
|
try {
|
||||||
if (n.effects) {
|
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);
|
collectIds(eff);
|
||||||
}
|
}
|
||||||
} catch (err) { /* ignore */ }
|
} catch (err) { /* ignore */ }
|
||||||
@@ -6037,7 +6040,10 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (n.effects) {
|
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;
|
foundId = findFirstId(eff) || foundId;
|
||||||
}
|
}
|
||||||
} catch (err) { /* ignore */ }
|
} catch (err) { /* ignore */ }
|
||||||
|
|||||||
Reference in New Issue
Block a user