public static async Task <DeveloperMessage> GetNextDeveloperMessage() { try { var messages = await DeveloperMessageApi.GetDeveloperMessages(); if (messages == null || messages.messages == null) { return(null); } var readMessageIds = LocalConfiguration.DeveloperMessageShownIds; var unreadMessages = messages.messages.Where(x => !readMessageIds.Contains(x.id)).ToList(); var firstUnreadMessage = unreadMessages.FirstOrDefault(); if (firstUnreadMessage == null) { return(null); } LocalConfiguration.AddIdToDeveloperMessageShownIds(firstUnreadMessage.id); return(firstUnreadMessage); } catch (Exception ex) { logger.Warn("GetNextDeveloperMessage failed: " + ex.ToString()); AnalyticsHelper.Log("exception-GetNextDeveloperMessage", ex.Message, ex.ToString()); return(null); } }
/// <returns>true if just injected the script, false if it was already injected.</returns> public async Task <bool> InjectInitScript(bool lightTheme) { var checkIfInjected = "((document.getElementsByTagName('body')[0].getAttribute('data-scriptinjection') == null) ? '0' : '1');"; var injected = await mainWebView.InvokeScriptAsync("eval", new string[] { checkIfInjected }); if (injected != "1") { var script = await AssetManager.LoadAssetString(lightTheme? "init-light.js" : "init-dark.js"); var styleCss = await AssetManager.LoadAssetString(lightTheme? "style-light.min.css" : "style-dark.min.css"); var tokens = TokenHelper.GetTokens(); script = script .Replace("{{XPOTIFYCSSBASE64CONTENT}}", Convert.ToBase64String(Encoding.UTF8.GetBytes(styleCss))) .Replace("{{XPOTIFYISPROVERSION}}", PackageHelper.IsProVersion ? "1" : "0") .Replace("{{SPOTIFYACCESSTOKEN}}", tokens.AccessToken) .Replace("{{DEVICENAME}}", DeviceInfoHelper.GetDeviceName()); try { await mainWebView.InvokeScriptAsync("eval", new string[] { script }); } catch (Exception ex) { logger.Warn("InjectInitScript failed: " + ex.ToString()); AnalyticsHelper.Log("injectException", ex.Message, $"{LastInitErrors}\n{ex}"); if (ex.ToString().Contains("80020101")) { MessageDialog md = new MessageDialog( content: $"Error details:\r\n\r\n{LastInitErrors}\r\n{ex}", title: "There was a problem while initializing Xpo Music. Some features might not work properly."); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed md.ShowAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } else { MessageDialog md = new MessageDialog( content: ex.ToString(), title: "Xpo Music initialization failed. Some features might not work properly."); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed md.ShowAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } } return(true); } return(false); }
private static void LogPlaybackStuck(string code) { ToastHelper.SendDebugToast("PlaybackStuck", code); AnalyticsHelper.Log("playbackStuck", code); logger.Info($"PlaybackStuck - {code}"); }