Skip to content

Commit

Permalink
After editing widget, show loading page instead of stale data (#264)
Browse files Browse the repository at this point in the history
* Show loading page instead of stale data after customization

* force immedaite data update request
  • Loading branch information
krschau authored Nov 8, 2023
1 parent 9dc9efe commit 865d4bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/GitHubExtension/Widgets/GitHubAssignedWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/GitHubExtension/Widgets/GitHubWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 865d4bc

Please sign in to comment.