diff --git a/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs b/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs index 11b3ca6c..2b78773e 100644 --- a/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs +++ b/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs @@ -85,8 +85,7 @@ namespace Yavsc.Helpers public async Task InvokeJson(object query) { JsonValue jsonDoc = null; - try - { + using (Stream streamQuery = request.GetRequestStream()) { using (StreamWriter writer = new StreamWriter(streamQuery)) @@ -102,7 +101,9 @@ namespace Yavsc.Helpers jsonDoc = await Task.Run(() => JsonObject.Load(stream)); } response.Close(); - } + } + try + { } catch (WebException ex) { diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index ed96d59b..e352f99a 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -33,7 +33,6 @@ namespace BookAStar public static IPlatform PlatformSpecificInstance { get; set; } public static string AppName { get; set; } - [Obsolete("Instead using this, use new static properties.")] public static App CurrentApp { get { return Current as App; } } @@ -64,7 +63,7 @@ namespace BookAStar MainSettings.UserChanged += MainSettings_UserChanged; CrossConnectivity.Current.ConnectivityChanged += (conSender, args) => { App.IsConnected = args.IsConnected; }; - SetupHubConnection(); + MainSettings_UserChanged(this, null); if (CrossConnectivity.Current.IsConnected) StartHubConnection(); } @@ -341,20 +340,21 @@ namespace BookAStar } ); }); - MainSettings_UserChanged(this, null); } private void MainSettings_UserChanged(object sender, EventArgs e) { if (MainSettings.CurrentUser == null) { - chatHubConnection.Headers.Clear(); + chatHubConnection.Dispose(); + chatHubConnection = null; + chatHubProxy = null; } else { var token = MainSettings.CurrentUser.YavscTokens.AccessToken; - chatHubConnection.Headers.Add( - "Authorization", $"Bearer {token}"); + SetupHubConnection(); + chatHubConnection.Headers.Add("Authorization", $"Bearer {token}"); } } diff --git a/BookAStar/BookAStar/Pages/UserProfile/UserProfilePage.xaml b/BookAStar/BookAStar/Pages/UserProfile/UserProfilePage.xaml index ba506934..790caa89 100644 --- a/BookAStar/BookAStar/Pages/UserProfile/UserProfilePage.xaml +++ b/BookAStar/BookAStar/Pages/UserProfile/UserProfilePage.xaml @@ -18,6 +18,9 @@ HorizontalTextAlignment="Center" LineBreakMode="WordWrap" XAlign="Center" > + +