-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: support managing predefined prompts with editing and replacement" #454
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,7 +317,8 @@ export default createStore({ | |
addPrompt.index = state.prompts.push(addPrompt) - 1; | ||
}, | ||
editPrompt(state, values) { | ||
const { index } = values; | ||
let { index } = values; | ||
index=index || state.prompts.length | ||
state.prompts[index] = { ...state.prompts[index], ...values }; | ||
}, | ||
Comment on lines
+320
to
323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement title comparison logic to align with PR objectives There's a discrepancy between the PR objectives and the current implementation of the
Here's a suggested implementation that aligns with the PR objectives: editPrompt(state, values) {
const { title, ...otherValues } = values;
const existingIndex = state.prompts.findIndex(prompt => prompt.title === title);
if (existingIndex !== -1) {
// If a prompt with the same title exists, update it
state.prompts[existingIndex] = { ...state.prompts[existingIndex], ...otherValues };
} else {
// If no prompt with the same title exists, create a new one
state.prompts.push({ title, ...otherValues });
}
}, This implementation ensures that the behavior matches the PR objectives and prevents unintended overwrites or duplications. |
||
deletePrompt(state, values) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not related to the topic.