From f4ab97c0889b89f4ef6642b3a34c4a13dffe5a65 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 4 Apr 2021 13:48:27 +0800 Subject: [PATCH] optimize: cache downloading failed avatars --- src/Helpers/Avatar.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Helpers/Avatar.cs b/src/Helpers/Avatar.cs index 4e2482a4..6abae634 100644 --- a/src/Helpers/Avatar.cs +++ b/src/Helpers/Avatar.cs @@ -190,15 +190,20 @@ namespace SourceGit.Helpers { reader.CopyTo(writer); } - if (requesting.ContainsKey(email)) { - Dispatcher.Invoke(() => { - var img = new BitmapImage(new Uri(filePath)); - loaded[email] = img; + Dispatcher.Invoke(() => { + var img = new BitmapImage(new Uri(filePath)); + loaded.Add(email, img); + + if (requesting.ContainsKey(email)) { foreach (var one in requesting[email]) one.Source = img; - }); - } + } + }); + } else { + loaded.Add(email, null); } - } catch { } + } catch { + loaded.Add(email, null); + } requesting.Remove(email); };