2
2
using CommunityToolkit . Mvvm . ComponentModel ;
3
3
using CommunityToolkit . Mvvm . Input ;
4
4
using Newtonsoft . Json . Linq ;
5
+ using System . Collections . ObjectModel ;
5
6
using System . Diagnostics ;
6
7
using System . Threading . Tasks ;
7
8
using VisGit . Core . Controllers ;
8
- using VisGit . Core . Interfaces ;
9
9
using VisGit . Core . Services ;
10
10
11
11
namespace VisGit . Core . ViewModels
12
12
{
13
- public partial class MainViewModel : ObservableObject
13
+ public partial class MainViewModel : BaseViewModel
14
14
{
15
15
#region Properties =========================================================================================
16
16
@@ -20,6 +20,17 @@ public partial class MainViewModel : ObservableObject
20
20
[ ObservableProperty ]
21
21
private string _visualStudioStatusText = string . Empty ;
22
22
23
+ // Repository objects
24
+ [ ObservableProperty ]
25
+ private ObservableCollection < RepositoryViewModel > _userRepositoryVMs ;
26
+
27
+ [ ObservableProperty ]
28
+ private RepositoryViewModel _selectedRespositoryVM ;
29
+
30
+ // Milestone objects
31
+ [ ObservableProperty ]
32
+ private ObservableCollection < MilestoneViewModel > _repositoryMilestonesVMs = new ObservableCollection < MilestoneViewModel > ( ) ;
33
+
23
34
#endregion End: Properties
24
35
25
36
#region Property Changed Methods =========================================================================================
@@ -29,6 +40,11 @@ partial void OnVisualStudioStatusTextChanged(string value)
29
40
_ = VS . StatusBar . ShowMessageAsync ( value ) ;
30
41
}
31
42
43
+ partial void OnSelectedRespositoryVMChanged ( RepositoryViewModel value )
44
+ {
45
+ _ = GetAllMilestonesForRepoAsync ( value . GitRepository . Id ) ;
46
+ }
47
+
32
48
#endregion End: Property Changed Methods
33
49
34
50
#region Operational Vars =========================================================================================
@@ -49,6 +65,7 @@ private void InitialiseView()
49
65
{
50
66
gitController = new GitController ( gitClient ) ;
51
67
TaskScheduler . UnobservedTaskException += TaskScheduler_UnobservedTaskException ;
68
+ UserRepositoryVMs = new ObservableCollection < RepositoryViewModel > ( ) ;
52
69
}
53
70
54
71
[ RelayCommand ]
@@ -60,6 +77,9 @@ private async Task AuthenticateUserAsync()
60
77
61
78
if ( UserAuthenicated ) UpdateVsStatusText ( "Login Successful" ) ;
62
79
else UpdateVsStatusText ( "Login error. Check connection and PAT." ) ;
80
+
81
+ // Now get all repos for user
82
+ await GetUserRespositoriesAsync ( ) ;
63
83
}
64
84
65
85
#endregion End: Commands
@@ -77,6 +97,18 @@ private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTask
77
97
//SingleLineFeedback = e.Exception.Message;
78
98
}
79
99
100
+ private async Task GetUserRespositoriesAsync ( )
101
+ {
102
+ UserRepositoryVMs . Clear ( ) ;
103
+ UserRepositoryVMs = await gitController . GetAllRepositoriesAsync ( ) ;
104
+ }
105
+
106
+ private async Task GetAllMilestonesForRepoAsync ( long repositoryId )
107
+ {
108
+ RepositoryMilestonesVMs . Clear ( ) ;
109
+ RepositoryMilestonesVMs = await gitController . GetAllMilestonesForRepoAsync ( repositoryId ) ;
110
+ }
111
+
80
112
#endregion End: Private Methods
81
113
82
114
public MainViewModel ( )
0 commit comments