Skip to content

Commit

Permalink
Add steps
Browse files Browse the repository at this point in the history
  • Loading branch information
tan-ha-wave5 committed Nov 27, 2024
1 parent a660c9e commit d5c24b2
Show file tree
Hide file tree
Showing 5 changed files with 780 additions and 637 deletions.
8 changes: 6 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"name": ".NET MAUI",
"type": "maui",
"request": "launch",
"preLaunchTask": "maui: Build"
},
{
"name": ".NET Meteor Debugger",
"type": "dotnet-meteor.debugger",
Expand Down
26 changes: 26 additions & 0 deletions src/Presentations/Windows/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/MAUIsland.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions src/Presentations/Windows/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Windows.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Windows.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Windows.sln"
],
"problemMatcher": "$msCompile"
}
]
}
103 changes: 99 additions & 4 deletions src/Presentations/Windows/Features/Home/Pages/HomePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.VisualElements;
using MAUIsland.Features.LocalDbFeatures.GitHub;
using MAUIsland.GitHubFeatures;
using SkiaSharp;

namespace MAUIsland.Home;
public partial class HomePageViewModel : NavigationAwareBaseViewModel
{
#region [ Fields ]

private readonly IHomeService homeService;
private readonly IGitHubService gitHubService;
private readonly IConversationService conversationService;
private readonly IGitHubIssueLocalDbService gitHubIssueLocalDbService;
#endregion

#region [ CTor ]
Expand All @@ -21,12 +22,14 @@ public HomePageViewModel(
IAppNavigator appNavigator,
IHomeService homeService,
IGitHubService gitHubService,
IConversationService conversationService
IConversationService conversationService,
IGitHubIssueLocalDbService gitHubIssueLocalDbService
) : base(appNavigator)
{
this.homeService = homeService;
this.gitHubService = gitHubService;
this.conversationService = conversationService;
this.gitHubIssueLocalDbService = gitHubIssueLocalDbService;
}
#endregion

Expand Down Expand Up @@ -162,7 +165,6 @@ IConversationService conversationService
#endregion

#region [ Methods ]

protected override void OnInit(IDictionary<string, object> query)
{
base.OnInit(query);
Expand Down Expand Up @@ -209,14 +211,84 @@ async Task OpenUrlAsync(string url)
#endregion

#region [ Methods ]

async Task LoadDotNetMauiRepoInfoAsync()
{
IsGitHubOpenIssuesChartLoading = true;

// new
await LoadIssuesAsync();

string repositoryAuthor = "dotnet";
string repositoryName = "maui";

var now = DateTime.UtcNow;

// First: sync from local db.
// TODO: how to get control name?
var allLocalDbIssues = await GetIssueByControlNameFromLocalDb(controlName);

// If localdb version is not null & not outdated => use local version.
if (allLocalDbIssues != null && allLocalDbIssues.Any() && !allLocalDbIssues.Any(x => (now - x.LastUpdated).TotalHours > 1)) {
if (ControlIssues is null || forced) {
ControlIssues = new(allLocalDbIssues.Select(x => new ControlIssueModel() {
IssueId = x.IssueId,
Title = x.Title,
IssueLinkUrl = x.IssueLinkUrl,
MileStone = x.MileStone,
OwnerName = x.OwnerName,
AvatarUrl = x.UserAvatarUrl,
CreatedDate = x.CreatedDate,
LastUpdated = x.LastUpdated
}));
}
IsBusy = false;

// Done.
return;
}

// If localdb does not have issue info, or info outdated => sync from GitHub & save.
var result = await GitHubService.GetGitHubIssuesByLabels(gitHubAuthorName,
gitHubrepositoryName,
labels);


if (result.IsT0) // Check if result is ServiceSuccess
{
var issues = result.AsT0.AttachedData as IEnumerable<GitHubIssueModel>;

// Save to localdb.
foreach (var issue in issues) {
await UpdateLocalIssue(issue, controlName);
}

IsBusy = false;

if (ControlIssues is null || forced) {
ControlIssues = new(issues.Select(x => new ControlIssueModel() {
IssueId = x.Id,
Title = x.Title,
IssueLinkUrl = x.HtmlUrl,
MileStone = x.Milestone is null ? "No mile stone" : x.Milestone.Title,
OwnerName = x.User.Login,
AvatarUrl = x.User.AvatarUrl,
CreatedDate = x.CreatedAt.DateTime,
LastUpdated = x.UpdatedAt is null ? x.CreatedAt.DateTime : x.UpdatedAt.Value.DateTime
}));
}
}
else {
IsBusy = false;

var error = result.AsT1;
EmptyViewText = error.ErrorDetail;
await AppNavigator.ShowSnackbarAsync(error.ErrorDetail,
async () => {
await AppNavigator.OpenUrlAsync(GitHubAPIRateLimit);
},
"Visit GitHub API Rate Limits Policies");
}

var openIssues = await gitHubService.GetGitHubIssues(repositoryAuthor, repositoryName);

if (openIssues.IsT1)
Expand Down Expand Up @@ -282,6 +354,29 @@ async Task LoadDotNetMauiRepoInfoAsync()
ReleaseInfo = releaseInfo.Name;
}

async Task LoadIssuesAsync() {
string repositoryAuthor = "dotnet";
string repositoryName = "maui";

var openIssues = await gitHubService.GetGitHubIssues(repositoryAuthor, repositoryName);

if (openIssues.IsT1)
return;

var latestRelease = await gitHubService.GetLatestRelease(repositoryAuthor, repositoryName);

var issuesList = openIssues.AsT0.AttachedData as IEnumerable<GitHubIssueModel>;


IssuesListCount = issuesList.Count();
AndroidIssuesCount = issuesList.Count(issue => issue.Labels.Any(label => label.Name.Equals("platform/android 🤖", StringComparison.OrdinalIgnoreCase)));
IosIssuesCount = issuesList.Count(issue => issue.Labels.Any(label => label.Name.Equals("platform/iOS 🍎", StringComparison.OrdinalIgnoreCase)));
WindowsIssueCount = issuesList.Count(issue => issue.Labels.Any(label => label.Name.Equals("platform/windows 🪟", StringComparison.OrdinalIgnoreCase)));
TizenIssuesCount = issuesList.Count(issue => issue.Labels.Any(label => label.Name.Equals("platform/tizen", StringComparison.OrdinalIgnoreCase)));

IsGitHubOpenIssuesChartLoading = false;
}

Task LoadBooks()
{
Items2.Add(new BookItem
Expand Down
Loading

0 comments on commit d5c24b2

Please sign in to comment.