From f8d85ef7293f72a1147c7c87baf3a79555f00040 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Thu, 21 May 2020 09:38:30 +0800 Subject: [PATCH] do not query follow/recommends when no cookie --- Pixiview/Illust/IllustCollectionPage.cs | 92 ++++++++++++++----------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index e262ffd..42ca64c 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -521,57 +521,65 @@ namespace Pixiview.Illust #region - Illust Tasks - + private async void RedirectFailed() + { + if (!IsRedirectLogin) + { + string extra; + if (lastError != null) + { + if (lastError.Length > 40) + { + extra = $"\n{lastError.Substring(0, 40)}..."; + } + else + { + extra = $"\n{lastError}"; + } + } + else + { + extra = string.Empty; + } + _ = DisplayAlert(ResourceHelper.Title, + ResourceHelper.FailedResponse + extra, + ResourceHelper.Ok); + } + else + { + var result = await DisplayAlert( + ResourceHelper.Title, + ResourceHelper.ConfirmLogin, + ResourceHelper.Yes, ResourceHelper.No); + if (result) + { + AppShell.Current.PushToLogin(() => + { + Task.Run(() => AppShell.Current.DoLoginInformation(true)); + StartLoad(true); + }); + } + } + IsLoading = false; + IsBottomLoading = false; + } + protected void DoLoadIllusts(bool force = false, bool bottom = false) { #if DEBUG App.DebugPrint($"start loading data, force: {force}"); #endif + if (force && string.IsNullOrEmpty(Configs.Cookie)) + { + MainThread.BeginInvokeOnMainThread(RedirectFailed); + App.DebugPrint($"no cookie found"); + return; + } illustData = DoLoadIllustData(force); if (illustData == null) { - MainThread.BeginInvokeOnMainThread(async () => - { - if (!IsRedirectLogin) - { - string extra; - if (lastError != null) - { - if (lastError.Length > 40) - { - extra = $"\n{lastError.Substring(0, 40)}..."; - } - else - { - extra = $"\n{lastError}"; - } - } - else - { - extra = string.Empty; - } - _ = DisplayAlert(ResourceHelper.Title, - ResourceHelper.FailedResponse + extra, - ResourceHelper.Ok); - } - else - { - var result = await DisplayAlert( - ResourceHelper.Title, - ResourceHelper.ConfirmLogin, - ResourceHelper.Yes, ResourceHelper.No); - if (result) - { - AppShell.Current.PushToLogin(() => - { - Task.Run(() => AppShell.Current.DoLoginInformation(true)); - StartLoad(true); - }); - } - } - }); + MainThread.BeginInvokeOnMainThread(RedirectFailed); //App.DebugError("illusts.load", "failed to load illusts data."); - IsLoading = false; - IsBottomLoading = false; return; } if (force && IsFavoriteVisible)