File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ export class BoardStore {
325325 // MULTI-BOARD MANAGEMENT
326326 // ============================================================================
327327
328- public getAllBoards ( ) : Array < { id : string ; name : string ; description ?: string ; createdAt : number ; updatedAt ?: number ; lastAccessed ?: number ; hasUnseenChanges ?: boolean } > {
328+ public getAllBoards ( ) : Array < { id : string ; name : string ; description ?: string ; createdAt : number ; updatedAt ?: number ; lastAccessed ?: number ; hasUnseenChanges ?: boolean ; author ?: string } > {
329329 // ⚡ KRITISCH: updateTrigger lesen für Reaktivität!
330330 this . updateTrigger ;
331331
@@ -395,7 +395,8 @@ export class BoardStore {
395395 lastAccessed : this . board . lastAccessedAt
396396 ? new Date ( this . board . lastAccessedAt ) . getTime ( )
397397 : new Date ( this . board . createdAt ) . getTime ( ) ,
398- hasUnseenChanges : this . board . hasUnseenChanges
398+ hasUnseenChanges : this . board . hasUnseenChanges ,
399+ author : this . board . author
399400 } ;
400401 } else {
401402 // Andere Boards: Lade frisches lastAccessedAt aus Storage
@@ -1132,7 +1133,7 @@ export class BoardStore {
11321133 this . deleteCard ( cardId ) ;
11331134 }
11341135
1135- public filterBoards ( query : string ) : Array < { id : string ; name : string ; description ?: string ; createdAt : number ; updatedAt ?: number ; lastAccessed ?: number ; hasUnseenChanges ?: boolean } > {
1136+ public filterBoards ( query : string ) : Array < { id : string ; name : string ; description ?: string ; createdAt : number ; updatedAt ?: number ; lastAccessed ?: number ; hasUnseenChanges ?: boolean ; author ?: string } > {
11361137 // ✅ BENUTZER-BASIERTE FILTERUNG: getAllBoards() liefert bereits gefilterte Boards
11371138 const userBoards = this . getAllBoards ( ) ;
11381139
Original file line number Diff line number Diff line change 162162 const ownBoards = boardStore .filterBoards (searchQuery );
163163 const sharedBoards = boardStore .filterSharedBoards (searchQuery );
164164
165- // Füge isShared: false zu eigenen Boards hinzu
166- const enrichedOwnBoards = ownBoards .map (board => ({
167- ... board ,
168- isShared: false ,
169- userRole: ' owner'
170- }));
165+ // Eigene Boards anreichern: Prüfe ob Board dem aktuellen User gehört
166+ // getAllBoards() gibt auch Boards zurück bei denen User Maintainer (Editor) ist!
167+ const currentPubkey = authStore .getPubkey ();
168+ const enrichedOwnBoards = ownBoards .map (board => {
169+ const isOwner = ! board .author || board .author === currentPubkey ;
170+ return {
171+ ... board ,
172+ isShared: ! isOwner ,
173+ userRole: isOwner ? ' owner' : ' editor'
174+ };
175+ });
171176
172177 // Kombiniere beide Listen und entferne Duplikate
173178 // ⚠️ WICHTIG: Bei Duplikaten (Board ist sowohl own als auch shared) bevorzuge shared-Metadaten
300305
301306 // Finde das Board in der gefilterten Liste um isShared und userRole zu prüfen
302307 const targetBoard = filteredBoards .find (b => b .id === boardId );
303- const isShared = targetBoard ?.isShared || false ;
304- const userRole = targetBoard ?.userRole || ' owner' ;
308+
309+ // Fallback: Wenn Board nicht in filteredBoards, prüfe ob es ein Fremd-Board ist
310+ const isShared = targetBoard ?.isShared ?? (boardStore .data ?.id === boardId && boardStore .data ?.author !== authStore .getPubkey () && !! boardStore .data ?.author );
311+ const storeRole = boardId === boardStore .data ?.id ? boardStore .getCurrentUserRole () : null ;
312+ const userRole = targetBoard ?.userRole ?? (storeRole === ' owner' ? ' owner' : storeRole === ' editor' ? ' editor' : storeRole === ' viewer' ? ' viewer' : ' owner' );
305313
306314 const actionText = isShared
307315 ? (userRole === ' owner' ? ' Board löschen' : ' Board verlassen' )
You can’t perform that action at this time.
0 commit comments