Skip to content

Commit

Permalink
#8 Ensure updated prompt always re-injected
Browse files Browse the repository at this point in the history
  • Loading branch information
Cohee1207 committed Dec 21, 2024
1 parent 7151808 commit 0c20e08
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,17 @@ function onEditPromptClick() {
$('#objective-prompt-generate').on('input', () => {
objectivePrompts.createTask = String($('#objective-prompt-generate').val());
saveState();
setCurrentTask();
});
$('#objective-prompt-check').on('input', () => {
objectivePrompts.checkTaskCompleted = String($('#objective-prompt-check').val());
saveState();
setCurrentTask();
});
$('#objective-prompt-extension-prompt').on('input', () => {
objectivePrompts.currentTask = String($('#objective-prompt-extension-prompt').val());
saveState();
setCurrentTask();
});

// Handle new
Expand Down Expand Up @@ -544,20 +547,22 @@ function saveCustomPrompt() {
}

async function deleteCustomPrompt() {
const confirmation = await Popup.show.confirm('Are you sure you want to delete this prompt?', null);
const customPromptName = String($('#objective-custom-prompt-select').find(':selected').val());

if (!confirmation) {
if (customPromptName == 'default') {
toastr.error('Cannot delete default prompt');
return;
}

const customPromptName = String($('#objective-custom-prompt-select').find(':selected').val());
const confirmation = await Popup.show.confirm('Are you sure you want to delete this prompt?', null);

if (customPromptName == 'default') {
toastr.error('Cannot delete default prompt');
if (!confirmation) {
return;
}

delete extension_settings.objective.customPrompts[customPromptName];
saveSettingsDebounced();
selectedCustomPrompt = 'default';
populateCustomPrompts(selectedCustomPrompt);
loadCustomPrompt();
}
Expand All @@ -572,6 +577,7 @@ function loadCustomPrompt() {
$('#objective-prompt-extension-prompt').val(objectivePrompts.currentTask).trigger('input');

saveState();
setCurrentTask();
}

/**
Expand Down

0 comments on commit 0c20e08

Please sign in to comment.