Fix Flash Message Method Calls
Flash Message Fixes: Changed this.flashMessageManager.show() to showMessage() Fixed all AI Tasks flash message calls to use correct method Removed unused 'type' parameter from flash messages All AI Tasks feedback messages should now display properly Error Resolved: TypeError: this.flashMessageManager.show is not a function AI connection test messages will now appear correctly Task generation success/failure messages working Configuration change notifications restored Expected Result: All AI Tasks operations should now show proper feedback messages Connection tests, task generation, and setting changes provide user feedback No more JavaScript errors when using AI features
This commit is contained in:
parent
727a0c0800
commit
478b5884fb
22
game.js
22
game.js
|
|
@ -4959,15 +4959,15 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
const isConnected = await this.aiTaskManager.testConnection();
|
||||
this.updateConnectionStatus();
|
||||
if (isConnected) {
|
||||
this.flashMessageManager.show('✅ Connected to Ollama successfully!', 'success');
|
||||
this.flashMessageManager.showMessage('✅ Connected to Ollama successfully!');
|
||||
} else {
|
||||
this.flashMessageManager.show('❌ Cannot connect to Ollama. Check if it\'s running.', 'error');
|
||||
this.flashMessageManager.showMessage('❌ Cannot connect to Ollama. Check if it\'s running.');
|
||||
}
|
||||
} else {
|
||||
this.flashMessageManager.show('⚠️ AI Manager not initialized', 'warning');
|
||||
this.flashMessageManager.showMessage('⚠️ AI Manager not initialized');
|
||||
}
|
||||
} catch (error) {
|
||||
this.flashMessageManager.show('❌ Connection test failed: ' + error.message, 'error');
|
||||
this.flashMessageManager.showMessage('❌ Connection test failed: ' + error.message);
|
||||
} finally {
|
||||
btn.textContent = originalText;
|
||||
btn.disabled = false;
|
||||
|
|
@ -4985,7 +4985,7 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
|
||||
if (!preview) {
|
||||
console.error('Test task output element not found');
|
||||
this.flashMessageManager.show('❌ UI element not found', 'error');
|
||||
this.flashMessageManager.showMessage('❌ UI element not found');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -4999,14 +4999,14 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
const task = await this.aiTaskManager.generateEdgingTask();
|
||||
preview.className = 'task-preview';
|
||||
preview.textContent = task.instruction || task.description || task;
|
||||
this.flashMessageManager.show('🎯 Test task generated successfully!', 'success');
|
||||
this.flashMessageManager.showMessage('🎯 Test task generated successfully!');
|
||||
} else {
|
||||
throw new Error('AI Manager not initialized');
|
||||
}
|
||||
} catch (error) {
|
||||
preview.className = 'task-preview error';
|
||||
preview.textContent = `Error generating task: ${error.message}`;
|
||||
this.flashMessageManager.show('❌ Failed to generate test task', 'error');
|
||||
this.flashMessageManager.showMessage('❌ Failed to generate test task');
|
||||
} finally {
|
||||
btn.textContent = originalText;
|
||||
btn.disabled = false;
|
||||
|
|
@ -5021,7 +5021,7 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
const model = e.target.value;
|
||||
if (this.aiTaskManager) {
|
||||
this.aiTaskManager.updateSettings({ model: model });
|
||||
this.flashMessageManager.show(`🔄 Switched to model: ${model}`, 'info');
|
||||
this.flashMessageManager.showMessage(`🔄 Switched to model: ${model}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -5057,7 +5057,7 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
const difficulty = e.target.value;
|
||||
if (this.aiTaskManager) {
|
||||
this.aiTaskManager.updateSettings({ difficulty: difficulty });
|
||||
this.flashMessageManager.show(`🎯 Difficulty set to: ${difficulty}`, 'info');
|
||||
this.flashMessageManager.showMessage(`🎯 Difficulty set to: ${difficulty}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -5080,7 +5080,7 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
const enabled = e.target.checked;
|
||||
if (this.aiTaskManager) {
|
||||
this.aiTaskManager.updateSettings({ enabled: enabled });
|
||||
this.flashMessageManager.show(`🤖 AI Tasks ${enabled ? 'enabled' : 'disabled'}`, 'info');
|
||||
this.flashMessageManager.showMessage(`🤖 AI Tasks ${enabled ? 'enabled' : 'disabled'}`);
|
||||
|
||||
// Update UI based on toggle
|
||||
const configSection = document.querySelector('.ai-config');
|
||||
|
|
@ -5098,7 +5098,7 @@ TaskChallengeGame.prototype.setupAITasksTabListeners = function() {
|
|||
const autoGenerate = e.target.checked;
|
||||
if (this.aiTaskManager) {
|
||||
this.aiTaskManager.updateSettings({ autoGenerate: autoGenerate });
|
||||
this.flashMessageManager.show(`🔄 Auto-generate ${autoGenerate ? 'enabled' : 'disabled'}`, 'info');
|
||||
this.flashMessageManager.showMessage(`🔄 Auto-generate ${autoGenerate ? 'enabled' : 'disabled'}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue