Merge pull request #757 from jellyfin/improve-like

refactor(like button): update data before requesting like/unlike from server
This commit is contained in:
Julien Machiels 2021-03-01 19:14:45 +01:00 committed by GitHub
commit c1ec56a120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,23 +59,27 @@ export default Vue.extend({
try {
if (!this.isFavorite) {
await this.$nuxt.$api.userLibrary.markFavoriteItem({
userId: this.$auth.user.Id,
itemId: this.item.Id
});
this.isFavorite = true;
} else {
await this.$nuxt.$api.userLibrary.unmarkFavoriteItem({
await this.$api.userLibrary.markFavoriteItem({
userId: this.$auth.user.Id,
itemId: this.item.Id
});
} else {
this.isFavorite = false;
await this.$api.userLibrary.unmarkFavoriteItem({
userId: this.$auth.user.Id,
itemId: this.item.Id
});
}
} catch {
this.pushSnackbarMessage({
message: this.$t('unableToToggleLike'),
color: 'error'
});
this.isFavorite = !this.isFavorite;
}
}
}