fix en refresh

This commit is contained in:
Vladimir Mandic
2023-09-07 16:15:42 -04:00
parent 5712a8cb20
commit a6dcb8c2f5
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ class StyleDatabase:
def reload(self):
self.styles.clear()
for fn in os.listdir(self.path):
if not fn.endswith(".json"):
if not fn.lower().endswith(".json"):
continue
with open(os.path.join(self.path, fn), 'r', encoding='utf-8') as f:
try:
+1
View File
@@ -369,6 +369,7 @@ def create_ui(container, button, tabname, skip_indexing = False):
for page in extra_pages:
if title == '' or title == page.title or len(page.html) == 0:
page.refresh()
page.refresh_time = None
page.create_page(ui.tabname)
shared.log.debug(f"Refreshing Extra networks: page={page.title} items={len(page.items)} tab={ui.tabname}")
res.append(page.html)
+6 -7
View File
@@ -13,20 +13,19 @@ class ExtraNetworksPageStyles(ui_extra_networks.ExtraNetworksPage):
shared.prompt_styles.reload()
def list_items(self):
styles = list(shared.prompt_styles.styles)
for style in styles:
path = os.path.join(shared.opts.styles_dir, style)
txt = f'Prompt: {shared.prompt_styles.styles[style].prompt}'
negative = shared.prompt_styles.styles[style].negative_prompt
for k in shared.prompt_styles.styles.keys():
path = os.path.join(shared.opts.styles_dir, k)
txt = f'Prompt: {shared.prompt_styles.styles[k].prompt}'
negative = shared.prompt_styles.styles[k].negative_prompt
if negative is not None and len(negative) > 0:
txt += f'\nNegative: {negative}'
yield {
"name": style,
"name": k,
"search_term": path,
"filename": path,
"preview": self.find_preview(path),
"description": txt,
"onclick": '"' + html.escape(f"""return selectStyle({json.dumps(style)})""") + '"',
"onclick": '"' + html.escape(f"""return selectStyle({json.dumps(k)})""") + '"',
"local_preview": f"{path}.{shared.opts.samples_format}",
}