feat(FalukantService, MessagesDialog): enhance character data handling in notifications
All checks were successful
Deploy to production / deploy (push) Successful in 2m3s
All checks were successful
Deploy to production / deploy (push) Successful in 2m3s
- Added mappings for character titles and genders in the FalukantService to enrich notifications with additional character information. - Updated the MessagesDialog component to utilize the new title and gender data, improving the display of director names based on their titles and genders. - Ensured that character names are displayed correctly, enhancing the overall user experience in notifications.
This commit is contained in:
@@ -8916,6 +8916,8 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
||||
if (!ids.length && !regionIdList.length) return;
|
||||
|
||||
const nameMap = new Map();
|
||||
const titleTrMap = new Map();
|
||||
const genderMap = new Map();
|
||||
if (ids.length) {
|
||||
const characters = await FalukantCharacter.findAll({
|
||||
where: { id: { [Op.in]: ids } },
|
||||
@@ -8928,12 +8930,13 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
||||
});
|
||||
|
||||
for (const c of characters) {
|
||||
const title = String(c.nobleTitle?.labelTr || '').trim();
|
||||
const first = c.definedFirstName?.name || '';
|
||||
const last = c.definedLastName?.name || '';
|
||||
const baseName = `${first} ${last}`.trim();
|
||||
const display = [title, baseName].filter(Boolean).join(' ').trim() || null;
|
||||
nameMap.set(Number(c.id), display || `#${c.id}`);
|
||||
const displayName = baseName || `#${c.id}`;
|
||||
nameMap.set(Number(c.id), displayName);
|
||||
titleTrMap.set(Number(c.id), String(c.nobleTitle?.labelTr || '').trim() || null);
|
||||
genderMap.set(Number(c.id), String(c.gender || '').trim() || null);
|
||||
}
|
||||
}
|
||||
let regionNameById = new Map();
|
||||
@@ -9008,6 +9011,17 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
||||
const resolved = nameMap.get(Number(foundId));
|
||||
// Set character_name directly (characterName is a getter that reads from character_name)
|
||||
n.character_name = resolved;
|
||||
const titleTr = titleTrMap.get(Number(foundId)) || null;
|
||||
const gender = genderMap.get(Number(foundId)) || null;
|
||||
if (n.dataValues) {
|
||||
if (parsed?.director_character_id != null) {
|
||||
n.dataValues.director_title_tr = titleTr;
|
||||
n.dataValues.director_gender = gender;
|
||||
} else {
|
||||
n.dataValues.character_title_tr = titleTr;
|
||||
n.dataValues.character_gender = gender;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parsed?.region_id != null && regionNameById.has(Number(parsed.region_id))) {
|
||||
|
||||
@@ -430,9 +430,18 @@ export default {
|
||||
|| base.event === 'director_resigned'
|
||||
|| (typeof base.tr === 'string' && (base.tr.includes('director.resignation') || base.tr.includes('director.resigned')));
|
||||
if (isDirectorResign) {
|
||||
params.directorName = params.characterName
|
||||
const baseName = params.characterName
|
||||
|| base.character_name
|
||||
|| (base.director_character_id != null ? `#${base.director_character_id}` : '');
|
||||
const titleTr = base.director_title_tr || base.character_title_tr || null;
|
||||
const gender = base.director_gender || base.character_gender || null;
|
||||
if (titleTr && gender) {
|
||||
const k = `falukant.titles.${gender}.${titleTr}`;
|
||||
const translatedTitle = this.$t(k);
|
||||
params.directorName = translatedTitle !== k ? `${translatedTitle} ${baseName}`.trim() : `${titleTr} ${baseName}`.trim();
|
||||
} else {
|
||||
params.directorName = baseName;
|
||||
}
|
||||
}
|
||||
if (base.director_id !== undefined) {
|
||||
params.director_id = base.director_id;
|
||||
|
||||
Reference in New Issue
Block a user