public static async void UpdateSnapchatData()
{
if (!SnapChatManager.IsAuthenticated()) return;
var forceLogout = false;
try
{
// Get Snapchat Updates
await ProgressHelper.ShowStatusBar(Loader.GetString("Updating"));
await SnapChatManager.UpdateAllAsync(async () => { await ProgressHelper.HideStatusBar(); }, Settings);
// Get ones to set notification count on
Settings.UnreadSnapCount = (uint)SnapChatManager.Account.Snaps.Count(s => s.SenderName != null && s.Status == SnapStatus.Delivered);
var mostRecent =
SnapChatManager.Account.Snaps.OrderByDescending(s => s.Timestamp)
.FirstOrDefault(s => s.SenderName != null && s.Status == SnapStatus.Delivered);
UpdateLiveTile(String.Format("New message from {0}", mostRecent.SenderName));
}
catch (InvalidCredentialsException exception)
{
SnazzyDebug.WriteLine(exception);
forceLogout = true;
}
catch (InvalidHttpResponseException exception)
{
if (exception.Message == "Unauthorized")
{
var dialog = new MessageDialog(Loader.GetString("UnauthorizedBody"), Loader.GetString("UnauthorizedHeader"));
dialog.ShowAsync();
forceLogout = true;
}
}
catch (Exception exception)
{
SnazzyDebug.WriteLine(exception);
}
if (forceLogout)
await LogoutAsync();
await ProgressHelper.HideStatusBar();
}