예제 #1
0
        public static void LogOutCommon(ITelegramEventAggregator eventAggregator, IMTProtoService mtProtoService, IUpdatesService updateService, ICacheService cacheService, IStateService stateService, IPushService pushService, INavigationService navigationService)
        {
            eventAggregator.Publish(Commands.LogOutCommand);

            SettingsHelper.SetValue(Constants.IsAuthorizedKey, false);
            SettingsHelper.RemoveValue(Constants.CurrentUserKey);
            mtProtoService.ClearQueue();
            updateService.ClearState();
            cacheService.ClearAsync();
            stateService.ResetPasscode();
            stateService.GetAllStickersAsync(result =>
            {
                var allStickers29 = result as TLAllStickers29;
                if (allStickers29 != null)
                {
                    allStickers29.RecentlyUsed = new TLVector <TLRecentlyUsedSticker>();
                }

                stateService.SaveAllStickersAsync(allStickers29);
            });
            SearchViewModel.DeleteRecentAsync();

            if (navigationService.CurrentSource == navigationService.UriFor <StartupViewModel>().BuildUri() ||
                navigationService.CurrentSource == navigationService.UriFor <SignInViewModel>().BuildUri() ||
                navigationService.CurrentSource == navigationService.UriFor <ConfirmViewModel>().BuildUri() ||
                navigationService.CurrentSource == navigationService.UriFor <SignUpViewModel>().BuildUri())
            {
                return;
            }

            stateService.ClearNavigationStack = true;
            Telegram.Logs.Log.Write("StartupViewModel SettingsViewModel.LogOutCommon");
            navigationService.UriFor <StartupViewModel>().Navigate();
        }
예제 #2
0
        private async void LogoutExecute()
        {
            var confirm = await TLMessageDialog.ShowAsync(Strings.Android.AreYouSureLogout, Strings.Android.AppName, Strings.Android.OK, Strings.Android.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            await _pushService.UnregisterAsync();

            var response = await ProtoService.LogOutAsync();

            if (response.IsSucceeded)
            {
                await _contactsService.RemoveAsync();

                SettingsHelper.IsAuthorized = false;
                SettingsHelper.UserId       = 0;
                //ProtoService.ClearQueue();
                _updatesService.ClearState();
                _stickersService.Cleanup();
                CacheService.ClearAsync();
                CacheService.ClearConfigImportAsync();

                App.Current.Exit();
            }
            else
            {
            }
        }
예제 #3
0
        private async void LogoutExecute()
        {
            var confirm = await TLMessageDialog.ShowAsync("Are you sure you want to logout?", "Unigram", "OK", "Cancel");

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            await _pushService.UnregisterAsync();

            var response = await ProtoService.LogOutAsync();

            if (response.IsSucceeded)
            {
                await _contactsService.UnsyncContactsAsync();

                SettingsHelper.IsAuthorized = false;
                SettingsHelper.UserId       = 0;
                ProtoService.ClearQueue();
                _updatesService.ClearState();
                _stickersService.Cleanup();
                CacheService.ClearAsync();
                CacheService.ClearConfigImportAsync();

                await TLMessageDialog.ShowAsync("The app will be closed. Relaunch it to login again.", "Unigram", "OK");

                App.Current.Exit();
            }
            else
            {
            }
        }
예제 #4
0
        public static void LogOutCommon(ITelegramEventAggregator eventAggregator, IMTProtoService mtProtoService, IUpdatesService updateService, ICacheService cacheService, IStateService stateService, IPushService pushService, INavigationService navigationService)
        {
            eventAggregator.Publish(Commands.LogOutCommand);

            SettingsHelper.SetValue(Constants.IsAuthorizedKey, false);
            SettingsHelper.RemoveValue(Constants.CurrentUserKey);
            mtProtoService.ClearQueue();
            updateService.ClearState();
            cacheService.ClearAsync();
            stateService.ResetPasscode();

            stateService.ClearAllStickersAsync();
            stateService.ClearFeaturedStickersAsync();
            stateService.ClearArchivedStickersAsync();

            EmojiControl emojiControl;

            if (EmojiControl.TryGetInstance(out emojiControl))
            {
                emojiControl.ClearStickersOnLogOut();
            }

            cacheService.ClearConfigImportAsync();
            SearchViewModel.DeleteRecentAsync();

            Bootstrapper.UpdateMainTile();

            DialogDetailsViewModel.DeleteInlineBots();
            FileUtils.Delete(new object(), Constants.InlineBotsNotificationFileName);
            FileUtils.Delete(new object(), Constants.WebPagePreviewsFileName);

            var liveLocationService = IoC.Get <ILiveLocationService>();

            liveLocationService.Clear();

            if (navigationService.CurrentSource == navigationService.UriFor <StartupViewModel>().BuildUri() ||
                navigationService.CurrentSource == navigationService.UriFor <SignInViewModel>().BuildUri() ||
                navigationService.CurrentSource == navigationService.UriFor <ConfirmViewModel>().BuildUri() ||
                navigationService.CurrentSource == navigationService.UriFor <SignUpViewModel>().BuildUri())
            {
                return;
            }

            stateService.ClearNavigationStack = true;
            Telegram.Logs.Log.Write("StartupViewModel SettingsViewModel.LogOutCommon");
            navigationService.UriFor <StartupViewModel>().Navigate();
        }