1
0
mirror of synced 2024-11-30 17:24:33 +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> </a>
</div> </div>
<div> <div>
<MudToggleIconButton <MudToggleIconButton Toggled="@context.IsFavorite"
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary" ToggledChanged="@(async () => await OnFavoriteToggled(context))"
ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary" Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary"
Size="Size.Small" ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary"
ToggledSize="Size.Small" Size="Size.Small"
Title="Add to favorites" ToggledSize="Size.Small"
ToggledTitle="Remove from favorites" /> Title="Add to favorites" ToggledTitle="Remove from favorites" />
</div> </div>
</MudStack> </MudStack>
</MudTd> </MudTd>

View File

@ -71,4 +71,19 @@ public partial class SongList
return true; 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;
}
}
} }