From 752215d3de56d975fa0b690fa10b3eb40ce05972 Mon Sep 17 00:00:00 2001 From: athulrajts Date: Sat, 7 Dec 2024 18:28:40 +0530 Subject: [PATCH] fix crash when there is no profile picture in tracker --- Totoro.WinUI/Helpers/Converters.cs | 11 +++++++++++ Totoro.WinUI/MainWindow.xaml | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Totoro.WinUI/Helpers/Converters.cs b/Totoro.WinUI/Helpers/Converters.cs index a2bc2f6..0534108 100644 --- a/Totoro.WinUI/Helpers/Converters.cs +++ b/Totoro.WinUI/Helpers/Converters.cs @@ -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() diff --git a/Totoro.WinUI/MainWindow.xaml b/Totoro.WinUI/MainWindow.xaml index 69e0e03..f191f65 100644 --- a/Totoro.WinUI/MainWindow.xaml +++ b/Totoro.WinUI/MainWindow.xaml @@ -43,8 +43,8 @@ + DisplayName="{x:Bind Shell.ViewModel.User.Name, Mode=OneWay}" + ProfilePicture="{x:Bind help:Converters.StringToImage(Shell.ViewModel.User.Name)}"/>