private async Task StartLoginSequence()
        {
            var dialog = new Dialogs.NiconicoLoginDialog();

            var currentStatus = await NiconicoSession.CheckSignedInStatus();

            if (currentStatus == Mntone.Nico2.NiconicoSignInStatus.ServiceUnavailable)
            {
                dialog.WarningText = "UnavailableNiconicoService".Translate();

                NotificationService.ShowInAppNotification(new InAppNotificationPayload()
                {
                    Content      = "UnavailableNiconicoService".Translate(),
                    ShowDuration = TimeSpan.FromSeconds(10)
                });
            }

            var account = await AccountManager.GetPrimaryAccount();

            if (account != null)
            {
                dialog.Mail     = account.Item1;
                dialog.Password = account.Item2;

                dialog.IsRememberPassword = true;
            }

            bool isLoginSuccess = false;
            bool isCanceled     = false;

            while (!isLoginSuccess)
            {
                var result = await dialog.ShowAsync();

                if (result != Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                {
                    isCanceled = true;
                    break;
                }

                dialog.WarningText = string.Empty;

                var loginResult = await NiconicoSession.SignIn(dialog.Mail, dialog.Password, true);

                if (loginResult == Mntone.Nico2.NiconicoSignInStatus.ServiceUnavailable)
                {
                    // サービス障害中
                    // 何か通知を出す?
                    NotificationService.ShowInAppNotification(new InAppNotificationPayload()
                    {
                        Content        = "UnavailableNiconicoService".Translate()
                        , ShowDuration = TimeSpan.FromSeconds(10)
                    });
                    break;
                }

                if (loginResult == Mntone.Nico2.NiconicoSignInStatus.TwoFactorAuthRequired)
                {
                    break;
                }

                if (loginResult == Mntone.Nico2.NiconicoSignInStatus.Failed)
                {
                    dialog.WarningText = "LoginFailed_WrongMailOrPassword".Translate();
                }

                isLoginSuccess = loginResult == Mntone.Nico2.NiconicoSignInStatus.Success;
            }

            // ログインを選択していた場合にのみアカウント情報を更新する
            // (キャンセル時は影響を発生させない)
            if (!isCanceled)
            {
                if (account != null)
                {
                    AccountManager.RemoveAccount(account.Item1);
                }

                if (dialog.IsRememberPassword)
                {
                    await AccountManager.AddOrUpdateAccount(dialog.Mail, dialog.Password);

                    AccountManager.SetPrimaryAccountId(dialog.Mail);
                }
                else
                {
                    AccountManager.SetPrimaryAccountId("");
                }
            }
        }
        private async Task StartLoginSequence()
        {
            var dialog = new Dialogs.NiconicoLoginDialog();



            var currentStatus = await NiconicoSession.CheckSignedInStatus();

            if (currentStatus == Mntone.Nico2.NiconicoSignInStatus.ServiceUnavailable)
            {
                dialog.WarningText = "【ニコニコサービス利用不可】\nメンテナンス中またはサービス障害が発生しているかもしれません";

                // TODO: トースト通知で障害発生中としてブラウザで開くアクションを提示?
            }
            if (currentStatus == Mntone.Nico2.NiconicoSignInStatus.TwoFactorAuthRequired)
            {
                dialog.WarningText = "二要素認証によるログインが必要です";
            }


            var account = await AccountManager.GetPrimaryAccount();

            if (account != null)
            {
                dialog.Mail     = account.Item1;
                dialog.Password = account.Item2;

                dialog.IsRememberPassword = true;
            }

            bool isLoginSuccess = false;
            bool isCanceled     = false;

            while (!isLoginSuccess)
            {
                var result = await dialog.ShowAsync();

                if (result != Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                {
                    isCanceled = true;
                    break;
                }

                dialog.WarningText = string.Empty;

                var loginResult = await NiconicoSession.SignIn(dialog.Mail, dialog.Password, true);

                if (loginResult == Mntone.Nico2.NiconicoSignInStatus.ServiceUnavailable)
                {
                    // サービス障害中
                    // 何か通知を出す?
                    NotificationService.ShowInAppNotification(new InAppNotificationPayload()
                    {
                        Content        = "【ニコニコサービス利用不可】\nサービスがメンテナンス中、また何らかの障害が発生しているかもしれません"
                        , ShowDuration = TimeSpan.FromSeconds(10)
                    });
                    break;
                }

                if (loginResult == Mntone.Nico2.NiconicoSignInStatus.TwoFactorAuthRequired)
                {
                    break;
                }

                if (loginResult == Mntone.Nico2.NiconicoSignInStatus.Failed)
                {
                    dialog.WarningText = "メールアドレスかパスワードが違うようです";
                }

                isLoginSuccess = loginResult == Mntone.Nico2.NiconicoSignInStatus.Success;
            }

            // ログインを選択していた場合にのみアカウント情報を更新する
            // (キャンセル時は影響を発生させない)
            if (!isCanceled)
            {
                if (account != null)
                {
                    AccountManager.RemoveAccount(account.Item1);
                }

                if (dialog.IsRememberPassword)
                {
                    await AccountManager.AddOrUpdateAccount(dialog.Mail, dialog.Password);

                    AccountManager.SetPrimaryAccountId(dialog.Mail);
                }
                else
                {
                    AccountManager.SetPrimaryAccountId("");
                }
            }
        }