Fixed a bug in modifing also the base arrays of prompts when translating
This commit is contained in:
parent
f022bce638
commit
8d964d4b1e
1 changed files with 4 additions and 3 deletions
|
|
@ -331,17 +331,18 @@ export async function setCustomPrompts(prompts) {
|
||||||
export async function getSpecialPrompts(){
|
export async function getSpecialPrompts(){
|
||||||
let prefs = await browser.storage.local.get({_special_prompts: null});
|
let prefs = await browser.storage.local.get({_special_prompts: null});
|
||||||
if(prefs._special_prompts === null){
|
if(prefs._special_prompts === null){
|
||||||
let def_specPrompts = [...specialPrompts];
|
let def_specPrompts = structuredClone(specialPrompts);
|
||||||
def_specPrompts.forEach((prompt) => {
|
def_specPrompts.forEach((prompt) => {
|
||||||
|
// console.log(">>>>>>>>>>>>> getSpecialPrompts prompt: " + JSON.stringify(prompt));
|
||||||
prompt.text = browser.i18n.getMessage(prompt.text);
|
prompt.text = browser.i18n.getMessage(prompt.text);
|
||||||
})
|
})
|
||||||
return def_specPrompts;
|
return def_specPrompts;
|
||||||
} else {
|
} else {
|
||||||
let updatedPrompts = [...prefs._special_prompts];
|
let updatedPrompts = structuredClone(prefs._special_prompts);
|
||||||
|
|
||||||
specialPrompts.forEach((defaultPrompt) => {
|
specialPrompts.forEach((defaultPrompt) => {
|
||||||
if (!updatedPrompts.some((prompt) => prompt.id === defaultPrompt.id)) {
|
if (!updatedPrompts.some((prompt) => prompt.id === defaultPrompt.id)) {
|
||||||
let newPrompt = { ...defaultPrompt };
|
let newPrompt = structuredClone(defaultPrompt);
|
||||||
newPrompt.text = browser.i18n.getMessage(newPrompt.text);
|
newPrompt.text = browser.i18n.getMessage(newPrompt.text);
|
||||||
updatedPrompts.push(newPrompt);
|
updatedPrompts.push(newPrompt);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue