1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-07 00:15:10 +01:00

Made code more robust against missing cache items

This commit is contained in:
2025-10-30 16:18:54 +01:00
parent 5eb9c606f0
commit cae9ebf3ef
3 changed files with 48 additions and 37 deletions

View File

@@ -34,6 +34,8 @@ class Settings(BaseSettings):
favicons_dir: DirectoryPath favicons_dir: DirectoryPath
# inside the codebase # inside the codebase
# static_dir: DirectoryPath = Path('digimarks/static')
# template_dir: DirectoryPath = Path('digimarks/templates')
static_dir: DirectoryPath = 'digimarks/static' static_dir: DirectoryPath = 'digimarks/static'
template_dir: DirectoryPath = 'digimarks/templates' template_dir: DirectoryPath = 'digimarks/templates'

View File

@@ -18,6 +18,7 @@ document.addEventListener('alpine:init', () => {
/* Bookmark that is being edited, used to fill the form, etc. */ /* Bookmark that is being edited, used to fill the form, etc. */
bookmarkToEdit: Alpine.$persist({}).as('bookmarkToEdit'), bookmarkToEdit: Alpine.$persist({}).as('bookmarkToEdit'),
bookmarkToEditError: null, bookmarkToEditError: null,
bookmarkToEditVisible: false,
/* Loading indicator */ /* Loading indicator */
loading: false, loading: false,
@@ -147,6 +148,10 @@ document.addEventListener('alpine:init', () => {
) )
}, },
get filteredTags() { get filteredTags() {
if (this.cache[this.userKey].tags === undefined) {
console.log('Tags not yet cached');
return [];
}
/* Search in the list of all tags */ /* Search in the list of all tags */
return this.cache[this.userKey].tags.filter( return this.cache[this.userKey].tags.filter(
i => i.match(new RegExp(this.search, "i")) i => i.match(new RegExp(this.search, "i"))
@@ -214,7 +219,6 @@ document.addEventListener('alpine:init', () => {
'note': '', 'note': '',
'tags': '' 'tags': ''
} }
}, },
async startAddingBookmark() { async startAddingBookmark() {
/* Open 'add bookmark' page */ /* Open 'add bookmark' page */
@@ -222,6 +226,7 @@ document.addEventListener('alpine:init', () => {
this.resetEditBookmark(); this.resetEditBookmark();
// this.show_bookmark_details = true; // this.show_bookmark_details = true;
const editFormDialog = document.getElementById("editFormDialog"); const editFormDialog = document.getElementById("editFormDialog");
this.bookmarkToEditVisible = true;
editFormDialog.showModal(); editFormDialog.showModal();
}, },
async bookmarkURLChanged() { async bookmarkURLChanged() {
@@ -253,6 +258,7 @@ document.addEventListener('alpine:init', () => {
}, },
async saveBookmark() { async saveBookmark() {
console.log('Saving bookmark'); console.log('Saving bookmark');
// this.bookmarkToEditVisible = false;
// this.show_bookmark_details = false; // this.show_bookmark_details = false;
}, },
async addBookmark() { async addBookmark() {

View File

@@ -185,7 +185,8 @@
</span> </span>
</div> </div>
#} #}
<form method="dialog" id="bookmarkEditForm" x-if="$store.digimarks.bookmarkToEdit"> <template x-if="$store.digimarks.bookmarkToEditVisible">
<form method="dialog" id="bookmarkEditForm">
<fieldset class="form-group"> <fieldset class="form-group">
<label for="bookmark_url">URL</label> <label for="bookmark_url">URL</label>
<input id="bookmark_url" type="text" name="bookmark_url" placeholder="url" <input id="bookmark_url" type="text" name="bookmark_url" placeholder="url"
@@ -210,7 +211,8 @@
placeholder="tags, divided bij comma's" placeholder="tags, divided bij comma's"
x-model="$store.digimarks.bookmarkToEdit.tags"> x-model="$store.digimarks.bookmarkToEdit.tags">
</fieldset> </fieldset>
<p x-show="$store.digimarks.bookmarkToEditError" x-data="$store.digimarks.bookmarkToEditError"></p> <p x-show="$store.digimarks.bookmarkToEditError"
x-data="$store.digimarks.bookmarkToEditError"></p>
<p> <p>
<label> <label>
<input type="checkbox" name="strip" id="strip"/> <input type="checkbox" name="strip" id="strip"/>
@@ -222,6 +224,7 @@
<button @click="$store.digimarks.saveBookmark()">Save</button> <button @click="$store.digimarks.saveBookmark()">Save</button>
</div> </div>
</form> </form>
</template>
</dialog> </dialog>
</main> </main>