Skip to content

Commit da23785

Browse files
committed
fix(demo): load missing cards
1 parent f496859 commit da23785

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/lib/stores/kanbanStore.svelte.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,9 @@ export class BoardStore {
33593359
// Board aus Event konvertieren
33603360
const boardProps = nostrEventToBoard(boardEvent);
33613361

3362+
console.log(`📋 Board hat ${boardProps.columns?.length || 0} Spalten:`,
3363+
boardProps.columns?.map(c => `${c.name} (${c.id})`) || []);
3364+
33623365
// Board mit neuer Demo-ID erstellen
33633366
// Use a valid dummy pubkey (64 zeros) instead of 'demo' to avoid Nostr validation errors
33643367
const board = new Board({
@@ -3383,19 +3386,34 @@ export class BoardStore {
33833386
console.log(`✅ ${cardEventArray.length} Card Events gefunden`);
33843387

33853388
// Cards zum Board hinzufügen
3389+
let cardsAdded = 0;
33863390
for (const cardEvent of cardEventArray) {
33873391
try {
33883392
const cardProps = nostrEventToCard(cardEvent as any) as any;
3389-
if (!cardProps.id) continue;
3393+
if (!cardProps.id) {
3394+
console.warn('⚠️ Card ohne ID übersprungen');
3395+
continue;
3396+
}
3397+
3398+
console.log(`🃏 Card: "${cardProps.heading}" → columnId: ${cardProps.columnId}, columnName: ${cardProps.columnName}`);
33903399

3391-
// Finde Spalte
3392-
const columnName = cardProps.columnName || 'To Do';
3393-
let column = board.columns.find(c => c.name === columnName);
3400+
// Finde Spalte (bevorzuge columnId, dann columnName)
3401+
let column = board.columns.find(c => c.id === cardProps.columnId);
3402+
3403+
if (!column && cardProps.columnName) {
3404+
// Fallback: Versuche nach Name zu finden
3405+
column = board.columns.find(c => c.name === cardProps.columnName);
3406+
}
33943407

33953408
if (!column) {
33963409
// Spalte existiert nicht, erstelle sie
3397-
column = board.addColumn({ name: columnName });
3398-
console.log(`📁 Spalte erstellt: ${columnName}`);
3410+
const columnName = cardProps.columnName || 'To Do';
3411+
const columnId = cardProps.columnId || generateDTag();
3412+
column = board.addColumn({
3413+
id: columnId,
3414+
name: columnName
3415+
});
3416+
console.log(`📁 Spalte erstellt: ${columnName} (ID: ${columnId})`);
33993417
}
34003418

34013419
// Card mit Demo-Attribution hinzufügen
@@ -3404,11 +3422,14 @@ export class BoardStore {
34043422
author: '0000000000000000000000000000000000000000000000000000000000000000', // Valid hex pubkey
34053423
authorName: 'Demo User'
34063424
});
3425+
cardsAdded++;
34073426
} catch (error) {
3408-
console.warn('⚠️ Fehler beim Hinzufügen einer Card:', error);
3427+
console.error('❌ Fehler beim Hinzufügen einer Card:', error);
34093428
}
34103429
}
34113430

3431+
console.log(`✅ ${cardsAdded} von ${cardEventArray.length} Cards erfolgreich hinzugefügt`);
3432+
34123433
// ⚡ CRITICAL: Sortiere Cards nach rank pro Spalte!
34133434
// ndk.fetchEvents() liefert keine garantierte Reihenfolge.
34143435
for (const col of board.columns) {

static/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454

5555
"demoBoard": {
56-
"sourceAddress": "naddr1qvzqqqrkt5pzpt8g7spkqtvt5wqau6xx2g98ptyyydzqetg7h47928hdml6f7stjqprxymmpwfjz6etxvd3rvdtrxcmrwcfkxvensdnxxgckye35vscn2d3j8quxzdpkxu6nxdrzvycxxwfjv56nge35vc6kgepnxvcrwd3hxf3rxepnxu6s7kr5h0",
56+
"sourceAddress": null,
5757
"$comment": "⚙️ Optional: Nostr address (naddr) of a board to use as demo template. If null, uses default demo board. Example: 'naddr1...'"
5858
},
5959

0 commit comments

Comments
 (0)