Skip to content

Commit

Permalink
Making default titles not be saved in data (#439)
Browse files Browse the repository at this point in the history
Co-authored-by: Felipe da Conceicao Guimaraes <[email protected]>
  • Loading branch information
guimafelipe and Felipe da Conceicao Guimaraes authored Aug 28, 2024
1 parent 0fbabbe commit 00d2e88
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubIssuesWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public override void LoadContentData()

issuesData.Add("issues", issuesArray);
issuesData.Add("selected_repo", repository?.FullName ?? string.Empty);
issuesData.Add("widgetTitle", WidgetTitle);
issuesData.Add("widgetTitle", GetActualTitle());
issuesData.Add("is_loading_data", DataState == WidgetDataState.Unknown);
issuesData.Add("issues_icon_data", _issuesIconData);

Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubPullsWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void LoadContentData()

pullsData.Add("pulls", pullsArray);
pullsData.Add("selected_repo", repository?.FullName ?? string.Empty);
pullsData.Add("widgetTitle", WidgetTitle);
pullsData.Add("widgetTitle", GetActualTitle());
pullsData.Add("is_loading_data", DataState == WidgetDataState.Unknown);
pullsData.Add("pulls_icon_data", _pullsIconData);

Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubReleasesWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public override void LoadContentData()

releasesData.Add("releases", releasesArray);
releasesData.Add("selected_repo", repository?.FullName ?? string.Empty);
releasesData.Add("widgetTitle", WidgetTitle);
releasesData.Add("widgetTitle", GetActualTitle());
releasesData.Add("is_loading_data", DataState == WidgetDataState.Unknown);
releasesData.Add("releases_icon_data", _releasesIconData);

Expand Down
16 changes: 5 additions & 11 deletions src/GitHubExtension/Widgets/GitHubRepositoryWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,11 @@ private void UpdateTitle(JsonNode? dataObj)
}

GetTitleFromDataObject(dataObj);
if (string.IsNullOrEmpty(WidgetTitle))
{
try
{
WidgetTitle = GetRepositoryFromUrl(RepositoryUrl).FullName;
}
catch
{
WidgetTitle = string.Empty;
}
}
}

protected string GetActualTitle()
{
return string.IsNullOrEmpty(WidgetTitle) ? GetRepositoryFromUrl(RepositoryUrl).FullName : WidgetTitle;
}

protected override void ResetWidgetInfoFromState()
Expand Down
16 changes: 11 additions & 5 deletions src/GitHubExtension/Widgets/GitHubUserWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ public override void OnWidgetContextChanged(WidgetContextChangedArgs contextChan

protected void UpdateTitle(JsonNode dataObj)
{
GetTitleFromDataObject(dataObj);
if (string.IsNullOrEmpty(WidgetTitle))
if (dataObj == null)
{
WidgetTitle = UserName;
return;
}

GetTitleFromDataObject(dataObj);
}

protected string GetActualTitle()
{
return string.IsNullOrEmpty(WidgetTitle) ? UserName : WidgetTitle;
}

protected override void ResetWidgetInfoFromState()
Expand Down Expand Up @@ -249,7 +255,7 @@ public override void LoadContentData()
{ "openCount", 0 },
{ "items", new JsonArray() },
{ "userName", UserName },
{ "widgetTitle", WidgetTitle },
{ "widgetTitle", GetActualTitle() },
{ "titleIconUrl", GetTitleIconData() },
{ "is_loading_data", true },
};
Expand Down Expand Up @@ -302,7 +308,7 @@ public void LoadContentData(IEnumerable<Octokit.Issue> items)
issuesData.Add("items", issuesArray);
issuesData.Add("userName", UserName);
issuesData.Add("titleIconUrl", GetTitleIconData());
issuesData.Add("widgetTitle", WidgetTitle);
issuesData.Add("widgetTitle", GetActualTitle());

LastUpdated = DateTime.Now;
ContentData = issuesData.ToJsonString();
Expand Down

0 comments on commit 00d2e88

Please sign in to comment.