{BUGFIX} On album update when no day is set for released field

This commit is contained in:
Damien Broqua 2024-01-18 20:46:40 +01:00
parent 2eb22bb3d6
commit 1a9728fce6

View File

@ -285,6 +285,27 @@ Publié automatiquement via #musictopus`;
}
}
/**
* Méthode permettant de récupérer le détails d'un album
*
* @return {Object}
*/
async getOne() {
const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user;
const album = await AlbumsModel.findOne({
_id,
User,
});
return {
...album.toJSON(),
released: album.released
? formatDate(album.released, "MM/dd/yyyy")
: null,
};
}
/**
* Méthode permettant de mettre à jour un album
*
@ -309,7 +330,9 @@ Publié automatiquement via #musictopus`;
const values = await getAlbumDetails(album.discogsId);
return AlbumsModel.findOneAndUpdate(query, values, { new: true });
await AlbumsModel.findOneAndUpdate(query, values, { new: true });
return this.getOne();
}
/**
@ -444,19 +467,7 @@ Publié automatiquement via #musictopus`;
* Méthode permettant d'afficher le détails d'un album
*/
async loadItem() {
const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user;
const album = await AlbumsModel.findOne({
_id,
User,
});
const item = {
...album.toJSON(),
released: album.released
? formatDate(album.released, "MM/dd/yyyy")
: null,
};
const item = await this.getOne();
this.setPageContent("item", item);
this.setPageTitle(