Fixed SongList page favorite button not working
This commit is contained in:
parent
e89566b61b
commit
08b136fe34
@ -92,13 +92,13 @@
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<MudToggleIconButton
|
||||
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary"
|
||||
ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary"
|
||||
Size="Size.Small"
|
||||
ToggledSize="Size.Small"
|
||||
Title="Add to favorites"
|
||||
ToggledTitle="Remove from favorites" />
|
||||
<MudToggleIconButton Toggled="@context.IsFavorite"
|
||||
ToggledChanged="@(async () => await OnFavoriteToggled(context))"
|
||||
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary"
|
||||
ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary"
|
||||
Size="Size.Small"
|
||||
ToggledSize="Size.Small"
|
||||
Title="Add to favorites" ToggledTitle="Remove from favorites" />
|
||||
</div>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
|
@ -71,4 +71,19 @@ public partial class SongList
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task OnFavoriteToggled(MusicDetail data)
|
||||
{
|
||||
var request = new SetFavoriteRequest
|
||||
{
|
||||
Baid = (uint)Baid,
|
||||
IsFavorite = !data.IsFavorite,
|
||||
SongId = data.SongId
|
||||
};
|
||||
var result = await Client.PostAsJsonAsync("api/FavoriteSongs", request);
|
||||
if (result.IsSuccessStatusCode)
|
||||
{
|
||||
data.IsFavorite = !data.IsFavorite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user