@@ -225,7 +225,7 @@ await Task.Run(() =>
225
225
226
226
picFavourite . SizeChanged += PicFavourite_SizeChanged ;
227
227
228
- bool favourite = songInfoStream ? . currentInfo . song . favorite ?? false ;
228
+ bool favourite = songInfoStream ? . currentInfo ? . song . favorite ?? false ;
229
229
picFavourite . Image = favourite ? favSprite . Frames [ favSprite . Frames . Length - 1 ] : favSprite . Frames [ 0 ] ;
230
230
231
231
ReloadScale ( ) ;
@@ -558,7 +558,7 @@ private void ReloadSprites()
558
558
picPlayPause . Image = Properties . Resources . play ;
559
559
}
560
560
561
- if ( songInfoStream ? . currentInfo . song . favorite ?? false )
561
+ if ( songInfoStream ? . currentInfo ? . song . favorite ?? false )
562
562
picFavourite . Image = favSprite ? . Frames [ favSprite . Frames . Length - 1 ] ;
563
563
else
564
564
picFavourite . Image = favSprite ? . Frames [ 0 ] ;
@@ -667,7 +667,10 @@ private void SetPlayPauseSize(bool bigger)
667
667
private void menuItemCopySongInfo_Click ( object sender , EventArgs e )
668
668
{
669
669
SongInfoResponseData info = songInfoStream . currentInfo ;
670
- Clipboard . SetText ( info . song . title + " \n " + string . Join ( ", " , info . song . artists . Select ( a => a . name ) ) + " \n " + info . song . source ) ;
670
+ if ( info != null )
671
+ {
672
+ Clipboard . SetText ( info . song . title + " \n " + string . Join ( ", " , info . song . artists . Select ( a => a . name ) ) + " \n " + info . song . source ) ;
673
+ }
671
674
}
672
675
673
676
private void picSettings_Click ( object sender , EventArgs e )
@@ -753,33 +756,39 @@ private async void SetFavouriteSprite(bool favourited)
753
756
}
754
757
755
758
isAnimating = false ;
756
- songInfoStream . currentInfo . song . favorite = true ;
759
+ if ( songInfoStream . currentInfo != null && songInfoStream . currentInfo . song != null )
760
+ songInfoStream . currentInfo . song . favorite = true ;
757
761
}
758
762
else
759
763
{
760
764
lock ( animationLock )
761
765
isAnimating = false ;
762
766
picFavourite . Image = favSprite . Frames [ 0 ] ;
763
- songInfoStream . currentInfo . song . favorite = false ;
767
+ if ( songInfoStream . currentInfo != null && songInfoStream . currentInfo . song != null )
768
+ songInfoStream . currentInfo . song . favorite = false ;
764
769
}
765
770
}
766
771
767
772
private async void picFavourite_Click ( object sender , EventArgs e )
768
773
{
769
- bool currentStatus = songInfoStream ? . currentInfo . song . favorite ?? false ;
774
+ bool currentStatus = songInfoStream ? . currentInfo ? . song . favorite ?? false ;
770
775
bool newStatus = ! currentStatus ;
771
- songInfoStream . currentInfo . song . favorite = newStatus ;
776
+
777
+ if ( songInfoStream . currentInfo != null && songInfoStream . currentInfo . song != null )
778
+ songInfoStream . currentInfo . song . favorite = newStatus ;
772
779
773
780
SetFavouriteSprite ( newStatus ) ;
774
781
775
782
( bool success , string result ) = await WebHelper . Post ( "https://listen.moe/api/songs/favorite" , Settings . Get < string > ( Setting . Token ) , new Dictionary < string , string > ( ) {
776
- [ "song" ] = songInfoStream . currentInfo . song . id . ToString ( )
783
+ [ "song" ] = songInfoStream ? . currentInfo ? . song . id . ToString ( ) ?? ""
777
784
} , true ) ;
778
785
779
786
var response = JsonConvert . DeserializeObject < FavouritesResponse > ( result ) ;
780
787
picFavourite . Image = response . favorite ? favSprite . Frames [ favSprite . Frames . Length - 1 ] :
781
788
spriteColorInverted ? darkFavSprite . Frames [ 0 ] : favSprite . Frames [ 0 ] ;
782
- songInfoStream . currentInfo . song . favorite = response . favorite ;
789
+
790
+ if ( songInfoStream . currentInfo != null && songInfoStream . currentInfo . song != null )
791
+ songInfoStream . currentInfo . song . favorite = response . favorite ;
783
792
}
784
793
785
794
private void menuItemResetLocation_Click ( object sender , EventArgs e )
0 commit comments