1
0
mirror of synced 2024-11-27 16:10:53 +01:00

Fixed SongList page favorite button not working

This commit is contained in:
S-Sebb 2024-07-01 15:51:49 +01:00
parent e89566b61b
commit 08b136fe34
2 changed files with 22 additions and 7 deletions

View File

@ -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>

View File

@ -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;
}
}
}