Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions studio/src/app/components/core/app-menu/app-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
});
}
Expand Down
2 changes: 1 addition & 1 deletion studio/src/app/services/data/deck/deck.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down