Skip to content

Commit

Permalink
fix crash when there is no profile picture in tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
insomniachi committed Dec 7, 2024
1 parent 2982be4 commit 752215d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Totoro.WinUI/Helpers/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ public static ImageSource StreamToImage(Stream stream)
return bmp;
}

public static ImageSource StringToImage(string uri)
{
if(string.IsNullOrEmpty(uri))
{
return null;
}

return new BitmapImage(new Uri(uri));
}


public static string ToOneBasedIndex(int number) => (number + 1).ToString();
public static string ToTitle(ChapterModel chapter) => string.IsNullOrEmpty(chapter.Title)
? chapter.Chapter.ToString()
Expand Down
4 changes: 2 additions & 2 deletions Totoro.WinUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<PersonPicture
Width="32"
Height="32"
DisplayName="{x:Bind Shell.ViewModel.User.Name, Mode=OneWay}"
ProfilePicture="{x:Bind Shell.ViewModel.User.Image, Mode=OneWay}" />
DisplayName="{x:Bind Shell.ViewModel.User.Name, Mode=OneWay}"
ProfilePicture="{x:Bind help:Converters.StringToImage(Shell.ViewModel.User.Name)}"/>
</Button>
</TitleBar.Footer>
</TitleBar>
Expand Down

0 comments on commit 752215d

Please sign in to comment.