Skip to content

Commit

Permalink
fix empty trigger word issue
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSandwich committed Aug 27, 2024
1 parent 681dc2f commit fbddae9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
11 changes: 9 additions & 2 deletions js/dragAreaEvent.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions js/navActions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions ts/dragAreaEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,28 @@ dropArea.addEventListener('drop', function (e) {

Promise.all(readTasksSyncPromises).then(function () {
var deletedDuplicatedTagCounter = 0;
var deletedEmptyTagCounter = 0; // won't happend actually because has filter when loaded txt file, keep for safe
for (const [key, value] of pair.entries()) {
if (value.ImgFilename == "" || value.PromptFilename == "") {
alert("Cannot find a pair for an instance, skip: \n\tImage: " + value.ImgFilename + "\n\tTxt: " + value.PromptFilename);
} else {
const oldSize = value.PromptLists.length;
var oldSize = value.PromptLists.length;
value.PromptLists = Array.from(new Set(value.PromptLists))
storage.push(value);

deletedDuplicatedTagCounter += oldSize - value.PromptLists.length;

oldSize = value.PromptLists.length;
value.PromptLists = value.PromptLists.filter(item => item != "");
deletedEmptyTagCounter += oldSize - value.PromptLists.length;

storage.push(value);
}
}
if (deletedDuplicatedTagCounter > 0) {
alert(`Deleted ${deletedDuplicatedTagCounter} duplicated tags!`);
}
if (deletedEmptyTagCounter > 0) {
alert(`Deleted ${deletedEmptyTagCounter} empty tags!`);
}

var generateTreeNodesPromises = [];

Expand Down
7 changes: 5 additions & 2 deletions ts/navActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,12 @@ function onNavbarExportClick() {
}

const zip = new JSZip();
const triggerWords = getTriggerWords().join(", ");
let triggerWords = getTriggerWords().join(", ");
if (triggerWords != "") {
triggerWords = triggerWords + ", ";
}
storage.forEach((item) => {
const prompt = triggerWords + ", " + item.PromptLists.filter(val => !triggerWords.includes(val)).join(", ");
const prompt = triggerWords + item.PromptLists.filter(val => !triggerWords.includes(val)).join(", ");
// const prompt = item.PromptLists.join(", ");
const textContent = new TextEncoder().encode(prompt);
const blob = new Blob([textContent], { type: "text/plain" });
Expand Down

0 comments on commit fbddae9

Please sign in to comment.