forked from FoundKeyGang/FoundKey
fix: handle exception in note favorites
This commit is contained in:
parent
2486eff747
commit
c6192ac95a
1 changed files with 3 additions and 1 deletions
|
@ -14,6 +14,7 @@ export const NoteFavoriteRepository = db.getRepository(NoteFavorite).extend({
|
|||
id: favorite.id,
|
||||
createdAt: favorite.createdAt.toISOString(),
|
||||
noteId: favorite.noteId,
|
||||
// may throw error
|
||||
note: await Notes.pack(favorite.note || favorite.noteId, me),
|
||||
};
|
||||
},
|
||||
|
@ -22,6 +23,7 @@ export const NoteFavoriteRepository = db.getRepository(NoteFavorite).extend({
|
|||
favorites: any[],
|
||||
me: { id: User['id'] }
|
||||
) {
|
||||
return Promise.all(favorites.map(x => this.pack(x, me)));
|
||||
return Promise.allSettled(favorites.map(x => this.pack(x, me)))
|
||||
.then(promises => promises.flatMap(result => result.status === 'fulfilled' ? [result.value] : []));
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue