From 428e35237feb80f1dc8aae59521c3ff835d90cc7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 29 Oct 2016 10:30:03 -0400 Subject: [PATCH] null checks around `Application.Current` for `SyncService`. --- src/App/Services/SyncService.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/App/Services/SyncService.cs b/src/App/Services/SyncService.cs index bf2bfd2a3..6523b17c0 100644 --- a/src/App/Services/SyncService.cs +++ b/src/App/Services/SyncService.cs @@ -54,8 +54,8 @@ namespace Bit.App.Services { SyncCompleted(false); - if(cipher.StatusCode == System.Net.HttpStatusCode.Forbidden - || cipher.StatusCode == System.Net.HttpStatusCode.Unauthorized) + if(Application.Current != null && (cipher.StatusCode == System.Net.HttpStatusCode.Forbidden + || cipher.StatusCode == System.Net.HttpStatusCode.Unauthorized)) { MessagingCenter.Send(Application.Current, "Logout", (string)null); } @@ -141,8 +141,8 @@ namespace Bit.App.Services { SyncCompleted(false); - if(ciphers.StatusCode == System.Net.HttpStatusCode.Forbidden - || ciphers.StatusCode == System.Net.HttpStatusCode.Unauthorized) + if(Application.Current != null && (ciphers.StatusCode == System.Net.HttpStatusCode.Forbidden + || ciphers.StatusCode == System.Net.HttpStatusCode.Unauthorized)) { MessagingCenter.Send(Application.Current, "Logout", (string)null); } @@ -200,8 +200,8 @@ namespace Bit.App.Services { SyncCompleted(false); - if(ciphers.StatusCode == System.Net.HttpStatusCode.Forbidden - || ciphers.StatusCode == System.Net.HttpStatusCode.Unauthorized) + if(Application.Current != null && (ciphers.StatusCode == System.Net.HttpStatusCode.Forbidden + || ciphers.StatusCode == System.Net.HttpStatusCode.Unauthorized)) { MessagingCenter.Send(Application.Current, "Logout", (string)null); } @@ -328,12 +328,22 @@ namespace Bit.App.Services private void SyncStarted() { + if(Application.Current == null) + { + return; + } + SyncInProgress = true; MessagingCenter.Send(Application.Current, "SyncStarted"); } private void SyncCompleted(bool successfully) { + if(Application.Current == null) + { + return; + } + SyncInProgress = false; MessagingCenter.Send(Application.Current, "SyncCompleted", successfully); }