Skip to content

Commit

Permalink
Better quality of code, no more hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe da Conceicao Guimaraes committed Aug 28, 2024
1 parent bfb2a48 commit 920107e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
5 changes: 2 additions & 3 deletions src/GitHubExtension/Widgets/GitHubReviewWidget.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Text.Json.Nodes;
using GitHubExtension.DataManager;
using GitHubExtension.Helpers;
using Microsoft.Windows.Widgets.Providers;
using Octokit;

namespace GitHubExtension.Widgets;

internal sealed class GitHubReviewWidget : GitHubUserWidget
{
protected override string DefaultShowCategory => "PullRequests";

protected override string GetTitleIconData()
{
return IconLoader.GetIconAsBase64("pulls.png");
Expand Down
6 changes: 4 additions & 2 deletions src/GitHubExtension/Widgets/GitHubUserWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ internal abstract class GitHubUserWidget : GitHubWidget

protected SearchCategory ShowCategory { get; set; } = SearchCategory.Unknown;

protected virtual string DefaultShowCategory => string.Empty;

private string _userName = string.Empty;

protected string UserName
Expand Down Expand Up @@ -115,7 +117,7 @@ protected override void ResetWidgetInfoFromState()
try
{
dataObject ??= JsonNode.Parse(ConfigurationData);
ShowCategory = EnumHelper.StringToSearchCategory(dataObject!["showCategory"]?.GetValue<string>() ?? string.Empty);
ShowCategory = EnumHelper.StringToSearchCategory(dataObject!["showCategory"]?.GetValue<string>() ?? DefaultShowCategory);
DeveloperLoginId = dataObject!["account"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);
}
Expand Down Expand Up @@ -147,7 +149,7 @@ public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)
return;
}

ShowCategory = EnumHelper.StringToSearchCategory(dataObject["showCategory"]?.GetValue<string>() ?? string.Empty);
ShowCategory = EnumHelper.StringToSearchCategory(dataObject["showCategory"]?.GetValue<string>() ?? DefaultShowCategory);
DeveloperLoginId = dataObject["account"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@
"label": "%Widget_Template/WidgetTitleLabel%",
"value": "${widgetTitle}"
},
{
"type": "Input.ChoiceSet",
"id": "showCategory",
"isMultiSelect": false,
"isVisible": false,
"value": "PullRequests",
"choices": [
{
"title": "%Widget_Template/PullRequests%",
"value": "PullRequests"
}
]
},
{
"type": "ColumnSet",
"columns": [
Expand Down

0 comments on commit 920107e

Please sign in to comment.