diff --git a/studio/src/app/components/core/app-menu/app-menu.tsx b/studio/src/app/components/core/app-menu/app-menu.tsx index 0981dc459..8aecb9e35 100644 --- a/studio/src/app/components/core/app-menu/app-menu.tsx +++ b/studio/src/app/components/core/app-menu/app-menu.tsx @@ -59,7 +59,6 @@ export class AppMenu { this.decks = await this.deckService.getUserDecks(authUser.uid); await this.filterDecks(null); } catch (err) { - // TODO: print error? this.decks = []; await this.filterDecks(null); } @@ -120,13 +119,18 @@ export class AppMenu { return filteredDeck.id === deck.id; }); - if (index < 0) { - this.decks = [deck, ...this.decks]; - } else { - this.decks[index].data.name = deck.data.name; - this.decks = [...this.decks]; + // New deck has been updated? If not, we don't have to update the list + if (index >= 0 && this.decks[index].data.updated_at && deck.data.updated_at && this.decks[index].data.updated_at.isEqual(deck.data.updated_at)) { + resolve(); + return; } + if (index >= 0) { + this.decks.splice(index, 1); + } + + this.decks = [deck, ...this.decks]; + resolve(); }); } diff --git a/studio/src/app/services/data/deck/deck.service.tsx b/studio/src/app/services/data/deck/deck.service.tsx index da9fa2734..75325bb13 100644 --- a/studio/src/app/services/data/deck/deck.service.tsx +++ b/studio/src/app/services/data/deck/deck.service.tsx @@ -85,7 +85,7 @@ export class DeckService { const snapshot: firebase.firestore.QuerySnapshot = await firestore.collection('decks') .where('owner_id', '==', userId) - .orderBy('created_at', 'desc') + .orderBy('updated_at', 'desc') .get(); const decks: Deck[] = snapshot.docs.map((documentSnapshot: firebase.firestore.QueryDocumentSnapshot) => {