Use ContinueWith to set Rating changed value
This commit is contained in:
parent
4725fe36d1
commit
fe804796ab
@ -57,6 +57,13 @@ namespace LibationAvalonia.ViewModels
|
|||||||
&& updateReviewTask?.IsCompleted is not false)
|
&& updateReviewTask?.IsCompleted is not false)
|
||||||
{
|
{
|
||||||
updateReviewTask = UpdateRating(value);
|
updateReviewTask = UpdateRating(value);
|
||||||
|
updateReviewTask.ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (t.Result)
|
||||||
|
LibraryBook.Book.UpdateUserDefinedItem(Book.UserDefinedItem.Tags, Book.UserDefinedItem.BookStatus, Book.UserDefinedItem.PdfStatus, value);
|
||||||
|
|
||||||
|
this.RaiseAndSetIfChanged(ref _myRating, value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,19 +82,14 @@ namespace LibationAvalonia.ViewModels
|
|||||||
|
|
||||||
#region User rating
|
#region User rating
|
||||||
|
|
||||||
private Task updateReviewTask;
|
private Task<bool> updateReviewTask;
|
||||||
private async Task UpdateRating(Rating rating)
|
private async Task<bool> UpdateRating(Rating rating)
|
||||||
{
|
{
|
||||||
var api = await LibraryBook.GetApiAsync();
|
var api = await LibraryBook.GetApiAsync();
|
||||||
|
|
||||||
if (await api.ReviewAsync(Book.AudibleProductId, (int)rating.OverallRating, (int)rating.PerformanceRating, (int)rating.StoryRating))
|
return await api.ReviewAsync(Book.AudibleProductId, (int)rating.OverallRating, (int)rating.PerformanceRating, (int)rating.StoryRating);
|
||||||
{
|
|
||||||
_myRating = rating;
|
|
||||||
LibraryBook.Book.UpdateUserDefinedItem(Book.UserDefinedItem.Tags, Book.UserDefinedItem.BookStatus, Book.UserDefinedItem.PdfStatus, rating);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.RaisePropertyChanged(nameof(MyRating));
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sorting
|
#region Sorting
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user