fix a config corruption bug

This commit is contained in:
mystie 2024-09-28 19:41:11 +03:00
parent d1d64ab954
commit bb733c8a9c
3 changed files with 10 additions and 6 deletions

View file

@ -1,3 +1,8 @@
## 1.5.6
### Fixes
* fix config file having extra data due to a request sending twice
## 1.5.5 ## 1.5.5
### Fixes ### Fixes

View file

@ -5,6 +5,6 @@ blacklistFile = 'word_blacklist.txt'
configFile = 'config.json' configFile = 'config.json'
faviconDir = Path.cwd() / 'static' / 'icons' / 'favicon' faviconDir = Path.cwd() / 'static' / 'icons' / 'favicon'
appName = 'CatAsk' appName = 'CatAsk'
version = '1.5.5' version = '1.5.6'
# id (identifier) is to be interpreted as described in https://semver.org/#spec-item-9 # id (identifier) is to be interpreted as described in https://semver.org/#spec-item-9
version_id = '-alpha' version_id = '-alpha'

View file

@ -13,7 +13,7 @@
<a class="visually-hidden-focusable" href="#preview">Skip to preview</a> <a class="visually-hidden-focusable" href="#preview">Skip to preview</a>
<div class="row"> <div class="row">
<div class="col mw-100"> <div class="col mw-100">
<form hx-trigger="click from:#saveConfig" hx-post="{{ url_for('api.updateConfig') }}" hx-target="#response-container" hx-swap="none"> <form hx-post="{{ url_for('api.updateConfig') }}" hx-target="#response-container" hx-swap="none">
<h2 id="instance" class="mb-3 fw-normal d-flex align-items-center justify-content-between"> <h2 id="instance" class="mb-3 fw-normal d-flex align-items-center justify-content-between">
Instance Instance
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-toggle="collapse" data-bs-target="#preview-collapse" aria-expanded="true" aria-controls="preview-collapse"><i class="bi bi-arrows-expand-vertical me-1"></i> Toggle preview</button> <button type="button" class="btn btn-outline-secondary btn-sm" data-bs-toggle="collapse" data-bs-target="#preview-collapse" aria-expanded="true" aria-controls="preview-collapse"><i class="bi bi-arrows-expand-vertical me-1"></i> Toggle preview</button>
@ -59,7 +59,7 @@
</form> </form>
<h2 id="customize" class="mb-3 fw-normal">Customize</h2> <h2 id="customize" class="mb-3 fw-normal">Customize</h2>
<h3 class="fw-light">Favicon</h3> <h3 class="fw-light">Favicon</h3>
<form hx-trigger="click from:#saveFavicon, keyup[ctrlKey&&key=='Enter']" hx-post="{{ url_for('api.uploadFavicon') }}" hx-target="#response-container" hx-swap="none" hx-encoding="multipart/form-data"> <form hx-post="{{ url_for('api.uploadFavicon') }}" hx-target="#response-container" hx-swap="none" hx-encoding="multipart/form-data">
<p class="m-0">Current favicon: <img src="{{ url_for('static', filename='icons/favicon/apple-touch-icon.png') }}" width="32" height="32" alt="{{ cfg.instance.title }}'s icon" class="rounded"></p> <p class="m-0">Current favicon: <img src="{{ url_for('static', filename='icons/favicon/apple-touch-icon.png') }}" width="32" height="32" alt="{{ cfg.instance.title }}'s icon" class="rounded"></p>
<div> <div>
<label for="favicon" class="form-label">Upload favicon</label> <label for="favicon" class="form-label">Upload favicon</label>
@ -73,7 +73,7 @@
</button> </button>
</div> </div>
</form> </form>
<form hx-trigger="click from:#saveConfig, keyup[ctrlKey&&key=='Enter']" hx-post="{{ url_for('api.updateConfig') }}" hx-target="#response-container" hx-swap="none"> <form hx-post="{{ url_for('api.updateConfig') }}" hx-target="#response-container" hx-swap="none">
<h3 class="fw-light">Accent color</h3> <h3 class="fw-light">Accent color</h3>
{# <h4 class="fw-light">Color</h4> #} {# <h4 class="fw-light">Color</h4> #}
<div class="form-group d-flex flex-column"> <div class="form-group d-flex flex-column">
@ -220,7 +220,7 @@
</div> </div>
</form> </form>
<hr class="mt-4 mb-4"> <hr class="mt-4 mb-4">
<form hx-trigger="click from:#save-blacklist, keyup[ctrlKey&&key=='Enter']" hx-post="{{ url_for('admin.index') }}" hx-target="#response-container" hx-swap="none"> <form hx-post="{{ url_for('admin.index') }}" hx-target="#response-container" hx-swap="none">
<input type="hidden" name="action" value="update_word_blacklist"> <input type="hidden" name="action" value="update_word_blacklist">
<div class="form-group mb-3"> <div class="form-group mb-3">
<label class="form-label" for="blacklist_cat"><h2 id="blacklist" class="fw-normal">Word blacklist</h2></label> <label class="form-label" for="blacklist_cat"><h2 id="blacklist" class="fw-normal">Word blacklist</h2></label>
@ -313,7 +313,6 @@
const forms = document.querySelectorAll('form'); const forms = document.querySelectorAll('form');
forms.forEach((form) => { forms.forEach((form) => {
form.addEventListener('htmx:afterRequest', function(event) { form.addEventListener('htmx:afterRequest', function(event) {
console.log("reached event listener");
const jsonResponse = event.detail.xhr.response; const jsonResponse = event.detail.xhr.response;
if (jsonResponse) { if (jsonResponse) {
const parsed = JSON.parse(jsonResponse); const parsed = JSON.parse(jsonResponse);