Fix: Use configured relationship emojis from tracker config instead of hardcoded defaults
- Load relationshipEmojis from config.relationshipEmojis in thoughts.js - Custom relationships added in Edit Trackers now display correctly as emojis - Falls back to default emojis if config not available
This commit is contained in:
@@ -217,8 +217,10 @@ export function onCharacterChanged() {
|
|||||||
// Load chat-specific data when switching chats
|
// Load chat-specific data when switching chats
|
||||||
loadChatData();
|
loadChatData();
|
||||||
|
|
||||||
// Commit tracker data from the last assistant message to initialize for this chat
|
// Don't call commitTrackerData() here - it would overwrite the loaded committedTrackerData
|
||||||
commitTrackerData();
|
// with data from the last message, which may be null/empty. The loaded committedTrackerData
|
||||||
|
// already contains the committed state from when we last left this chat.
|
||||||
|
// commitTrackerData() will be called naturally when new messages arrive.
|
||||||
|
|
||||||
// Re-render with the loaded data
|
// Re-render with the loaded data
|
||||||
renderUserStats();
|
renderUserStats();
|
||||||
|
|||||||
@@ -215,8 +215,8 @@ export function renderThoughts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relationship status to emoji mapping (for backward compatibility with old "relationship" field)
|
// Get relationship emojis from config (with fallback defaults)
|
||||||
const relationshipEmojis = {
|
const relationshipEmojis = config?.relationshipEmojis || {
|
||||||
'Enemy': '⚔️',
|
'Enemy': '⚔️',
|
||||||
'Neutral': '⚖️',
|
'Neutral': '⚖️',
|
||||||
'Friend': '⭐',
|
'Friend': '⭐',
|
||||||
@@ -498,6 +498,10 @@ export function updateCharacterField(characterName, field, value) {
|
|||||||
let statsLineExists = false;
|
let statsLineExists = false;
|
||||||
let statsLineIndex = -1;
|
let statsLineIndex = -1;
|
||||||
|
|
||||||
|
// Get the configured thoughts field name
|
||||||
|
const thoughtsFieldName = presentCharsConfig?.thoughts?.name || 'Thoughts';
|
||||||
|
const isThoughtsField = field.toLowerCase() === 'thoughts' || field === thoughtsFieldName;
|
||||||
|
|
||||||
// First pass: check if Stats line exists and update other fields
|
// First pass: check if Stats line exists and update other fields
|
||||||
for (let i = characterStartIndex; i < characterEndIndex; i++) {
|
for (let i = characterStartIndex; i < characterEndIndex; i++) {
|
||||||
const line = lines[i].trim();
|
const line = lines[i].trim();
|
||||||
@@ -530,6 +534,11 @@ export function updateCharacterField(characterName, field, value) {
|
|||||||
const relationshipValue = emojiToRelationship[value] || value;
|
const relationshipValue = emojiToRelationship[value] || value;
|
||||||
lines[i] = `Relationship: ${relationshipValue}`;
|
lines[i] = `Relationship: ${relationshipValue}`;
|
||||||
}
|
}
|
||||||
|
else if (isThoughtsField && line.startsWith(thoughtsFieldName + ':')) {
|
||||||
|
// Update thoughts field
|
||||||
|
lines[i] = `${thoughtsFieldName}: ${value}`;
|
||||||
|
console.log('[RPG Companion] Updated thoughts:', lines[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle stat updates
|
// Handle stat updates
|
||||||
|
|||||||
Reference in New Issue
Block a user