From 48acd5ce414ff7ddf723f924cd1dbbf1893dd319 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 25 Mar 2016 18:17:50 +0000 Subject: [PATCH] note controller: Don't fetch avatar on first run --- SparkleShare/Mac/EmptyXmlFile.xml | 2 ++ SparkleShare/SparkleNoteController.cs | 34 +++++++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 SparkleShare/Mac/EmptyXmlFile.xml diff --git a/SparkleShare/Mac/EmptyXmlFile.xml b/SparkleShare/Mac/EmptyXmlFile.xml new file mode 100644 index 00000000..aec79602 --- /dev/null +++ b/SparkleShare/Mac/EmptyXmlFile.xml @@ -0,0 +1,2 @@ + + diff --git a/SparkleShare/SparkleNoteController.cs b/SparkleShare/SparkleNoteController.cs index 47809d25..3ea76a52 100755 --- a/SparkleShare/SparkleNoteController.cs +++ b/SparkleShare/SparkleNoteController.cs @@ -16,9 +16,10 @@ using System; -using System.Net; using System.Threading; +using SparkleLib; + namespace SparkleShare { public class SparkleNoteController { @@ -29,20 +30,17 @@ namespace SparkleShare { public event UpdateTitleEventDelegate UpdateTitleEvent = delegate { }; public delegate void UpdateTitleEventDelegate (string title); - public string AvatarFilePath = ""; + public readonly string AvatarFilePath = ""; public string CurrentProject { get; private set; } public SparkleNoteController () { - Program.Controller.ShowNoteWindowEvent += delegate (string project) { - CurrentProject = project; - ShowWindowEvent (); - UpdateTitleEvent (CurrentProject); - }; + Program.Controller.ShowNoteWindowEvent += OnNoteWindowEvent; - AvatarFilePath = SparkleAvatars.GetAvatar (Program.Controller.CurrentUser.Email, - 48, Program.Controller.Config.FullPath); + if (Program.Controller.AvatarsEnabled && !Program.Controller.FirstRun) + AvatarFilePath = SparkleAvatars.GetAvatar (Program.Controller.CurrentUser.Email, + 48, Program.Controller.Config.FullPath); } @@ -55,7 +53,7 @@ namespace SparkleShare { public void SyncClicked (string note) { HideWindowEvent (); - new Thread (() => Program.Controller.GetRepoByName (CurrentProject).Resume (note)).Start (); + new Thread (() => ResumeWithNote (note)).Start (); } @@ -63,5 +61,21 @@ namespace SparkleShare { { HideWindowEvent (); } + + + void OnNoteWindowEvent (string project) + { + CurrentProject = project; + + ShowWindowEvent (); + UpdateTitleEvent (CurrentProject); + } + + + void ResumeWithNote (string note) + { + SparkleRepoBase repo = Program.Controller.GetRepoByName (CurrentProject); + repo.Resume (note); + } } }