From 865d4bc4e0f1a0adbc14ab9196d1a2c64058ca90 Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Wed, 8 Nov 2023 02:05:27 -0500 Subject: [PATCH] After editing widget, show loading page instead of stale data (#264) * Show loading page instead of stale data after customization * force immedaite data update request --- .../Widgets/GitHubAssignedWidget.cs | 4 ++++ .../Widgets/GitHubMentionedInWidget.cs | 4 ++++ src/GitHubExtension/Widgets/GitHubWidget.cs | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs b/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs index 452c0c0a..ce1c6336 100644 --- a/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs @@ -126,6 +126,10 @@ public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs) if (dataObject != null && dataObject.ShowCategory != null) { ShowCategory = EnumHelper.StringToSearchCategory(dataObject.ShowCategory); + + // If we got here during the customization flow, we need to LoadContentData again + // so we can show the loading page rather than stale data. + LoadContentData(); UpdateActivityState(); } } diff --git a/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs b/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs index a5dd1c1c..0667fac8 100644 --- a/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs @@ -146,6 +146,10 @@ public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs) if (dataObject != null && dataObject.ShowCategory != null) { ShowCategory = EnumHelper.StringToSearchCategory(dataObject.ShowCategory); + + // If we got here during the customization flow, we need to LoadContentData again + // so we can show the loading page rather than stale data. + LoadContentData(); UpdateActivityState(); } } diff --git a/src/GitHubExtension/Widgets/GitHubWidget.cs b/src/GitHubExtension/Widgets/GitHubWidget.cs index f18afe0a..90865037 100644 --- a/src/GitHubExtension/Widgets/GitHubWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubWidget.cs @@ -140,7 +140,21 @@ public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs) break; case WidgetAction.Save: + // Set loading page while we swap out the data. + Page = WidgetPageState.Loading; + + // It might take some time to get the new data, so + // set data state to "unknown" so that loading page is shown. + DataState = WidgetDataState.Unknown; + UpdateWidget(); + SavedRepositoryUrl = string.Empty; + LoadContentData(); + + // Reset the throttle time and force an immediate data update request. + LastUpdated = DateTime.MinValue; + RequestContentData(); + SetActive(); break;