Skip to content

Commit

Permalink
Don't use unnecessary onUIUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikDoom committed Nov 1, 2022
1 parent f8a9223 commit d5de786
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions javascript/tagAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ function navigateInList(textArea, event) {
event.stopPropagation();
}

var styleAdded = false;
onUiUpdate(async function () {
// One-time setup
document.addEventListener("DOMContentLoaded", async () => {
// Get our tag base path from the temp file
let tagBasePath = await readFile("file/tmp/tagAutocompletePath.txt");

Expand Down Expand Up @@ -640,7 +640,7 @@ onUiUpdate(async function () {
}
}
// Load wildcards
if (wildcardFiles.length === 0 && acConfig.useWildcards) {
if (acConfig.useWildcards && wildcardFiles.length === 0) {
try {
let wcFileArr = (await readFile(`file/${tagBasePath}/temp/wc.txt`)).split("\n");
let wcBasePath = wcFileArr[0].trim(); // First line should be the base path
Expand Down Expand Up @@ -676,7 +676,7 @@ onUiUpdate(async function () {
}
}
// Load embeddings
if (embeddings.length === 0 && acConfig.useEmbeddings) {
if (acConfig.useEmbeddings && embeddings.length === 0) {
try {
embeddings = (await readFile(`file/${tagBasePath}/temp/emb.txt`)).split("\n")
.filter(x => x.trim().length > 0) // Remove empty lines
Expand Down Expand Up @@ -707,7 +707,6 @@ onUiUpdate(async function () {
}

textAreas.forEach(area => {

// Return if autocomplete is disabled for the current area type in config
let textAreaId = getTextAreaIdentifier(area);
if ((!acConfig.activeIn.img2img && textAreaId.includes("img2img"))
Expand Down Expand Up @@ -773,8 +772,6 @@ onUiUpdate(async function () {
quicksettings.parentNode.insertBefore(optionsDiv, quicksettings.nextSibling);
}

if (styleAdded) return;

// Add style to dom
let acStyle = document.createElement('style');
let css = gradioApp().querySelector('.dark') ? autocompleteCSS_dark : autocompleteCSS_light;
Expand Down

0 comments on commit d5de786

Please sign in to comment.