public void ResetAccount()
        {
            BeginOnUIThread(TimeSpan.FromSeconds(0.1), () =>
            {
                var r = MessageBox.Show(AppResources.ResetMyAccountConfirmation, AppResources.Warning, MessageBoxButton.OKCancel);
                if (r != MessageBoxResult.OK)
                {
                    return;
                }

                IsWorking = true;
                MTProtoService.DeleteAccountAsync(
                    new TLString("Forgot password"),
                    result => BeginOnUIThread(() =>
                {
                    IsWorking = false;

                    StateService.RemoveBackEntry = true;
                    StateService.SentCode        = _sentCode;
                    NavigationService.UriFor <SignUpViewModel>().Navigate();
                }),
                    error => BeginOnUIThread(() =>
                {
                    IsWorking = false;

                    if (error.TypeEquals("2FA_RECENT_CONFIRM"))
                    {
                        MessageBox.Show(AppResources.ResetAccountError, AppResources.Error, MessageBoxButton.OK);
                    }
                    else if (error.TypeStarsWith("2FA_CONFIRM_WAIT"))
                    {
                        var message = error.Message.ToString().Replace("2FA_CONFIRM_WAIT_", string.Empty);
                        try
                        {
                            var confirmWait          = Convert.ToInt32(message);
                            StateService.ConfirmWait = confirmWait;
                            StateService.SentCode    = _sentCode;
                            NavigationService.UriFor <ResetAccountViewModel>().Navigate();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    else
                    {
                        Execute.ShowDebugMessage("account.deleteAccount error " + error);
                    }
                }));
            });
        }
Exemplo n.º 2
0
        public void ResetAccount()
        {
            IsWorking = true;
            MTProtoService.DeleteAccountAsync(
                new TLString("Forgot password"),
                result => BeginOnUIThread(() =>
            {
                IsWorking = false;

                StateService.RemoveBackEntry = true;
                StateService.SentCode        = _sentCode;
                NavigationService.UriFor <SignUpViewModel>().Navigate();
            }),
                error => BeginOnUIThread(() =>
            {
                IsWorking = false;

                if (error.TypeEquals("2FA_RECENT_CONFIRM"))
                {
                    MessageBox.Show(AppResources.ResetAccountError, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeStarsWith("2FA_CONFIRM_WAIT"))
                {
                    var message = error.Message.ToString().Replace("2FA_CONFIRM_WAIT_", string.Empty);
                    try
                    {
                        var confirmWait = Convert.ToInt32(message);
                        UpdateInterval(confirmWait);
                        _timer.Start();
                    }
                    catch (Exception e)
                    {
                    }
                }
                else
                {
                    Telegram.Api.Helpers.Execute.ShowDebugMessage("account.deleteAccount error " + error);
                }
            }));
        }
Exemplo n.º 3
0
        public void ResetAccount()
        {
            var r = MessageBox.Show(AppResources.ResetMyAccountConfirmation, AppResources.Warning, MessageBoxButton.OKCancel);

            if (r != MessageBoxResult.OK)
            {
                return;
            }

            IsWorking = true;
            MTProtoService.DeleteAccountAsync(new TLString("Forgot password"),
                                              result => BeginOnUIThread(() =>
            {
                IsWorking = false;

                StateService.RemoveBackEntry = true;
                NavigationService.UriFor <SignUpViewModel>().Navigate();
            }),
                                              error =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("account.deleteAccount error " + error);
            });
        }