This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed
src/GitHub.App/ViewModels Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Windows . Media . Imaging ;
33using GitHub . Models ;
4+ using GitHub . Primitives ;
45using GitHub . Services ;
56
67namespace GitHub . ViewModels
@@ -16,10 +17,30 @@ public ActorViewModel()
1617 public ActorViewModel ( ActorModel model )
1718 {
1819 Login = model ? . Login ?? "[unknown]" ;
19- Avatar = model ? . AvatarUrl != null ?
20- new BitmapImage ( new Uri ( model . AvatarUrl ) ) :
21- AvatarProvider . CreateBitmapImage ( DefaultAvatar ) ;
22- AvatarUrl = model ? . AvatarUrl ?? DefaultAvatar ;
20+
21+ if ( model ? . AvatarUrl != null )
22+ {
23+ try
24+ {
25+ var uri = new Uri ( model . AvatarUrl ) ;
26+
27+ // Image requests to enterprise hosts over https always fail currently,
28+ // so just display the default avatar. See #1547.
29+ if ( uri . Scheme != "https" ||
30+ uri . Host . EndsWith ( "githubusercontent.com" , StringComparison . OrdinalIgnoreCase ) )
31+ {
32+ AvatarUrl = model . AvatarUrl ;
33+ Avatar = new BitmapImage ( new Uri ( AvatarUrl ) ) ;
34+ }
35+ }
36+ catch { }
37+ }
38+
39+ if ( AvatarUrl == null )
40+ {
41+ Avatar = AvatarProvider . CreateBitmapImage ( DefaultAvatar ) ;
42+ AvatarUrl = DefaultAvatar ;
43+ }
2344 }
2445
2546 public BitmapSource Avatar { get ; set ; }
You can’t perform that action at this time.
0 commit comments