File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535
3636 try
3737 {
38+ Http .DefaultRequestHeaders .Add (" Cache-Control" , " no-cache" );
3839 var markdown = await Http .GetStringAsync (" Dashboard.md" );
3940
4041 if (! string .IsNullOrWhiteSpace (markdown ))
Original file line number Diff line number Diff line change 3333 else
3434 {
3535 <MudItem xs =" 12" >
36- <MudTable Class =" mud-table-outlined" Items =" @songHistoryDataMap.Values.ToList()" Elevation =" 0" Filter =@FilterSongs RowsPerPage =" 25 " Striped =" false" Hover =" false" Bordered =" false" Dense =" true" Breakpoint =Breakpoint.None >
36+ <MudTable Class =" mud-table-outlined" Items =" @songHistoryDataMap.Values.ToList()" Elevation =" 0" Filter =@FilterSongs RowsPerPage =" @rowsPerPage " RowsPerPageChanged = " OnRowsPerPageChanged " Striped =" false" Hover =" false" Bordered =" false" Dense =" true" Breakpoint =Breakpoint.None >
3737 <ToolBarContent >
3838 <MudGrid Spacing =" 2" Justify =" Justify.SpaceBetween" >
3939 <MudItem xs =" 12" md =" 4" Style =" align-content: center;" >
8181 @* Song title *@
8282 <MudTd DataLabel =" Song" Style =" text-align: initial !important;" >
8383 <MudStack Row =" true" Spacing =" 1" AlignItems =" AlignItems.Center" Justify =" Justify.SpaceBetween" >
84+ <div style =" margin : 4px ;" >
85+ <MudToggleIconButton Toggled =" songHistoryData.IsFavorite"
86+ ToggledChanged =" @(async () => await OnFavoriteToggled(songHistoryData, songHistoryDataMap.Values.ToList()))"
87+ Icon =" @Icons.Material.Filled.FavoriteBorder" Color =" @Color.Secondary"
88+ ToggledIcon =" @Icons.Material.Filled.Favorite" ToggledColor =" @Color.Secondary"
89+ Size =" Size.Small"
90+ ToggledSize =" Size.Small"
91+ Title =" Add to favorites" ToggledTitle =" Remove from favorites" />
92+ </div >
8493 <div style =" margin : 4px ; display : flex ;" >
8594 <MudIcon Style =@IconStyle Icon =" @GetDifficultyIcon(songHistoryData.Difficulty)" />
8695 </div >
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ public partial class PlayHistory
2222
2323 private Dictionary < uint , MusicDetail > musicDetailDictionary = new ( ) ;
2424
25+ private int rowsPerPage = 25 ;
26+
2527
2628 protected override async Task OnInitializedAsync ( )
2729 {
@@ -179,19 +181,35 @@ private bool FilterSongs(List<SongHistoryData> songHistoryDataList)
179181 return false ;
180182 }
181183
182- private async Task OnFavoriteToggled ( SongHistoryData data )
184+ private async Task OnFavoriteToggled ( SongHistoryData data , List < List < SongHistoryData > > array )
183185 {
184186 var request = new SetFavoriteRequest
185187 {
186188 Baid = ( uint ) Baid ,
187189 IsFavorite = ! data . IsFavorite ,
188190 SongId = data . SongId
189191 } ;
192+
190193 var result = await Client . PostAsJsonAsync ( "api/FavoriteSongs" , request ) ;
191194 if ( result . IsSuccessStatusCode )
192195 {
193196 data . IsFavorite = ! data . IsFavorite ;
197+ foreach ( var songHistoryDataArray in array )
198+ {
199+ foreach ( var songHistoryData in songHistoryDataArray )
200+ {
201+ if ( songHistoryData . SongId == data . SongId )
202+ {
203+ songHistoryData . IsFavorite = request . IsFavorite ;
204+ }
205+ }
206+ }
194207 }
195208 }
209+
210+ private void OnRowsPerPageChanged ( int pageSize )
211+ {
212+ rowsPerPage = pageSize ;
213+ }
196214}
197215
You can’t perform that action at this time.
0 commit comments