Spaces:
Paused
Paused
Fix: Correct db update method, iterate all decks, respect user's custom deck
Browse files- index.html +1 -1
- src/app.js +11 -9
- src/db/database.js +6 -2
- src/views/vocabulary-modal.js +4 -0
index.html
CHANGED
|
@@ -74,7 +74,7 @@
|
|
| 74 |
</head>
|
| 75 |
<body class="dark-theme in-chat-view" style="visibility: hidden;">
|
| 76 |
|
| 77 |
-
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.
|
| 78 |
|
| 79 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 80 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
|
|
|
| 74 |
</head>
|
| 75 |
<body class="dark-theme in-chat-view" style="visibility: hidden;">
|
| 76 |
|
| 77 |
+
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.319</div>
|
| 78 |
|
| 79 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 80 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
src/app.js
CHANGED
|
@@ -366,14 +366,16 @@ Zu übersetzen: "${word}"`;
|
|
| 366 |
if (window.isOverlayMode) return;
|
| 367 |
|
| 368 |
let decks = db.getDecks();
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
const
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
|
|
|
|
|
|
| 377 |
|
| 378 |
if (cardsToEnrich.length > 0) {
|
| 379 |
console.log(`Found ${cardsToEnrich.length} cards needing AI enrichment...`);
|
|
@@ -422,7 +424,7 @@ Beispiel für Tippfehler bei "abanden":
|
|
| 422 |
const finalFront = parsed.correctedWord ? parsed.correctedWord : card.front;
|
| 423 |
|
| 424 |
// Update the card in the database
|
| 425 |
-
db.
|
| 426 |
|
| 427 |
// Dispatch event so UI can refresh if user is looking at flashcards
|
| 428 |
window.dispatchEvent(new CustomEvent('flashcards-updated'));
|
|
|
|
| 366 |
if (window.isOverlayMode) return;
|
| 367 |
|
| 368 |
let decks = db.getDecks();
|
| 369 |
+
if (!decks || decks.length === 0) return;
|
| 370 |
+
|
| 371 |
+
let cardsToEnrich = [];
|
| 372 |
+
for (const deck of decks) {
|
| 373 |
+
const cards = db.getCardsForDeck(deck.id);
|
| 374 |
+
cardsToEnrich.push(...cards.filter(c =>
|
| 375 |
+
c.back.includes('<!-- NEEDS_ENRICHMENT -->') ||
|
| 376 |
+
(!c.back.includes('**Erklärung:**') && !c.back.includes('Erklärung:'))
|
| 377 |
+
));
|
| 378 |
+
}
|
| 379 |
|
| 380 |
if (cardsToEnrich.length > 0) {
|
| 381 |
console.log(`Found ${cardsToEnrich.length} cards needing AI enrichment...`);
|
|
|
|
| 424 |
const finalFront = parsed.correctedWord ? parsed.correctedWord : card.front;
|
| 425 |
|
| 426 |
// Update the card in the database
|
| 427 |
+
db.editFlashcard(card.id, finalFront, finalBack, imageUrl);
|
| 428 |
|
| 429 |
// Dispatch event so UI can refresh if user is looking at flashcards
|
| 430 |
window.dispatchEvent(new CustomEvent('flashcards-updated'));
|
src/db/database.js
CHANGED
|
@@ -539,9 +539,13 @@ class Database {
|
|
| 539 |
this.exec("DELETE FROM flashcards WHERE id = ?", [cardId]);
|
| 540 |
}
|
| 541 |
|
| 542 |
-
editFlashcard(cardId, front, back) {
|
| 543 |
const now = new Date().toISOString();
|
| 544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
}
|
| 546 |
|
| 547 |
// SM-2 Algorithm update
|
|
|
|
| 539 |
this.exec("DELETE FROM flashcards WHERE id = ?", [cardId]);
|
| 540 |
}
|
| 541 |
|
| 542 |
+
editFlashcard(cardId, front, back, imageUrl = null) {
|
| 543 |
const now = new Date().toISOString();
|
| 544 |
+
if (imageUrl !== null) {
|
| 545 |
+
this.exec("UPDATE flashcards SET front = ?, back = ?, image_url = ?, updated_at = ? WHERE id = ?", [front, back, imageUrl, now, cardId]);
|
| 546 |
+
} else {
|
| 547 |
+
this.exec("UPDATE flashcards SET front = ?, back = ?, updated_at = ? WHERE id = ?", [front, back, now, cardId]);
|
| 548 |
+
}
|
| 549 |
}
|
| 550 |
|
| 551 |
// SM-2 Algorithm update
|
src/views/vocabulary-modal.js
CHANGED
|
@@ -262,6 +262,10 @@ Nur das rohe JSON:`;
|
|
| 262 |
// 2. Save to Vault (Flashcard DB)
|
| 263 |
let decks = db.getDecks();
|
| 264 |
let schnelldeck = decks.find(d => d.title === 'Schnelleingabe' || d.title === 'Inbox');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
if (!schnelldeck) {
|
| 266 |
schnelldeck = db.createDeck('Schnelleingabe', 'Automatisch gespeicherte Vokabeln aus der Schnelleingabe', '#8a53e6', 'Englisch', 'Deutsch');
|
| 267 |
}
|
|
|
|
| 262 |
// 2. Save to Vault (Flashcard DB)
|
| 263 |
let decks = db.getDecks();
|
| 264 |
let schnelldeck = decks.find(d => d.title === 'Schnelleingabe' || d.title === 'Inbox');
|
| 265 |
+
if (!schnelldeck && decks.length > 0) {
|
| 266 |
+
// If the user renamed it, just use their first available deck
|
| 267 |
+
schnelldeck = decks[0];
|
| 268 |
+
}
|
| 269 |
if (!schnelldeck) {
|
| 270 |
schnelldeck = db.createDeck('Schnelleingabe', 'Automatisch gespeicherte Vokabeln aus der Schnelleingabe', '#8a53e6', 'Englisch', 'Deutsch');
|
| 271 |
}
|