Skip to content

Commit 962b3d3

Browse files
committed
fix(default board): does not create it always
1 parent b15cdd1 commit 962b3d3

File tree

1 file changed

+48
-26
lines changed

1 file changed

+48
-26
lines changed

src/lib/stores/kanbanStore.svelte.ts

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ export class BoardStore {
6969

7070
private initializeBoard(): void {
7171
const currentBoardId = this.board.id;
72+
73+
// ⚠️ FIX: Don't save placeholder board!
74+
if (currentBoardId === 'placeholder-board') {
75+
console.log('📝 Placeholder board active - nicht speichern');
76+
return;
77+
}
78+
7279
if (!this.boardIds.includes(currentBoardId)) {
73-
console.log('🔥 Erstes Laden: Füge Default Board zur Liste hinzu:', currentBoardId);
80+
console.log('🔥 Erstes Laden: Füge Board zur Liste hinzu:', currentBoardId);
7481
this.boardIds = [...this.boardIds, currentBoardId];
7582
// BoardStorage.saveBoardIds() removed - deprecated, auto-discovered from localStorage
7683
this.saveToStorage();
@@ -254,8 +261,17 @@ export class BoardStore {
254261
const boardIds = BoardStorage.loadBoardIds();
255262

256263
if (boardIds.length === 0) {
257-
console.log('📝 Keine Boards gefunden, erstelle Default-Board');
258-
return BoardStorage.createDefaultBoard();
264+
// ⚠️ FIX: Don't create default board automatically!
265+
// Anonymous users should only see demo board (via getAllBoards() → getDemoBoardsForAnonymousUser())
266+
// New authenticated users should start with empty board list (can create boards via UI)
267+
console.log('📝 Keine Boards gefunden - erstelle Platzhalter-Board');
268+
return new Board({
269+
id: 'placeholder-board',
270+
name: 'Willkommen',
271+
description: 'Erstellen Sie Ihr erstes Board oder laden Sie die Demo',
272+
author: 'anonymous',
273+
columns: []
274+
});
259275
}
260276

261277
const boards = BoardStorage.getAllBoardsMetadata(boardIds);
@@ -278,11 +294,25 @@ export class BoardStore {
278294
}
279295
}
280296

281-
console.log('⚠️ Keine Boards gefunden, erstelle Default-Board');
282-
return BoardStorage.createDefaultBoard();
297+
// ⚠️ FIX: This should not happen (boards.length > 0 but couldn't load any)
298+
// Return placeholder instead of creating default board
299+
console.log('⚠️ Boards in list but couldn\'t load any - erstelle Platzhalter');
300+
return new Board({
301+
id: 'placeholder-board',
302+
name: 'Willkommen',
303+
description: 'Erstellen Sie Ihr erstes Board oder laden Sie die Demo',
304+
author: 'anonymous',
305+
columns: []
306+
});
283307
}
284308

285309
private saveToStorage(): void {
310+
// ⚠️ FIX: Don't save placeholder board!
311+
if (this.board.id === 'placeholder-board') {
312+
console.log('⏭️ Skipping save for placeholder board');
313+
return;
314+
}
315+
286316
BoardStorage.saveBoard(this.board);
287317
console.log(`💾 Saved board "${this.board.name}" with lastAccessedAt:`, this.board.lastAccessedAt);
288318
}
@@ -338,8 +368,8 @@ export class BoardStore {
338368
return this.getDemoBoardsForAnonymousUser();
339369
}
340370

341-
// ⚡ FIX: Authentifizierte Benutzer - Demo-Board explizit ausschließen
342-
const filteredBoardIds = this.boardIds.filter(id => id !== 'demo-board');
371+
// ⚡ FIX: Authentifizierte Benutzer - Demo-Board und Placeholder explizit ausschließen
372+
const filteredBoardIds = this.boardIds.filter(id => id !== 'demo-board' && id !== 'placeholder-board');
343373
const allBoards = BoardStorage.getAllBoardsMetadata(filteredBoardIds);
344374

345375
// 🔍 DEBUG: Log all boards and their authors
@@ -3214,25 +3244,17 @@ export class BoardStore {
32143244
if (shouldReloadFromSource) {
32153245
this.demoBoardLoadInProgress = true; // 🚨 Set flag!
32163246

3217-
// ⚠️ CRITICAL FIX: Don't create empty placeholder board!
3218-
// If we create new Board with columns: [], users see empty board while loading.
3219-
// Instead: Keep existing demoBoard (has old content) and trigger async reload.
3220-
// Users see old content during load, then it gets replaced with fresh content.
3221-
3222-
// If no existing board, create placeholder (only happens on first load)
3223-
if (!demoBoard) {
3224-
demoBoard = new Board({
3225-
id: demoBoardId,
3226-
name: '⏳ Demo-Board wird geladen...',
3227-
description: 'Das Demo-Board wird von der konfigurierten Quelle geladen. Bitte warten Sie einen Moment.',
3228-
author: '0000000000000000000000000000000000000000000000000000000000000000',
3229-
authorName: 'Demo User',
3230-
publishState: 'private',
3231-
columns: []
3232-
});
3233-
BoardStorage.saveBoard(demoBoard);
3234-
}
3235-
// else: Keep existing demoBoard with its content (columns/cards) while loading
3247+
// Erstelle zunächst ein leeres Platzhalter-Board synchron
3248+
demoBoard = new Board({
3249+
id: demoBoardId,
3250+
name: '⏳ Demo-Board wird geladen...',
3251+
description: 'Das Demo-Board wird von der konfigurierten Quelle geladen. Bitte warten Sie einen Moment.',
3252+
author: '0000000000000000000000000000000000000000000000000000000000000000', // Valid hex pubkey
3253+
authorName: 'Demo User',
3254+
publishState: 'private',
3255+
columns: []
3256+
});
3257+
BoardStorage.saveBoard(demoBoard);
32363258

32373259
// Lade Board asynchron im Hintergrund
32383260
this.loadDemoBoardFromSourceAsync(sourceAddress).then(loadedBoard => {

0 commit comments

Comments
 (0)