File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
src/CodingWithCalvin.CouchbaseExplorer/ViewModels Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,14 @@ protected override async void OnExpanded()
3434 await LoadScopesAsync ( ) ;
3535 }
3636
37+ public async Task RefreshAsync ( )
38+ {
39+ _hasLoadedScopes = false ;
40+ Children . Clear ( ) ;
41+ Children . Add ( new PlaceholderNode { Name = "Refreshing..." } ) ;
42+ await LoadScopesAsync ( ) ;
43+ }
44+
3745 public async Task LoadScopesAsync ( )
3846 {
3947 IsLoading = true ;
Original file line number Diff line number Diff line change @@ -150,14 +150,32 @@ private async void OnConnectRequested(ConnectionNode connection)
150150 await ConnectToNodeAsync ( connection ) ;
151151 }
152152
153- private void OnRefresh ( object parameter )
153+ private async void OnRefresh ( object parameter )
154154 {
155- // TODO: Refresh selected node or all connections
155+ var node = parameter as TreeNodeBase ?? SelectedNode ;
156+ if ( node == null )
157+ {
158+ return ;
159+ }
160+
161+ switch ( node )
162+ {
163+ case ConnectionNode connection when connection . IsConnected :
164+ await LoadBucketsAsync ( connection ) ;
165+ break ;
166+ case BucketNode bucket :
167+ await bucket . RefreshAsync ( ) ;
168+ break ;
169+ case ScopeNode scope :
170+ await scope . RefreshAsync ( ) ;
171+ break ;
172+ }
156173 }
157174
158175 private bool CanRefresh ( object parameter )
159176 {
160- return SelectedNode != null || Connections . Count > 0 ;
177+ var node = parameter as TreeNodeBase ?? SelectedNode ;
178+ return node is ConnectionNode conn ? conn . IsConnected : node is BucketNode || node is ScopeNode ;
161179 }
162180
163181 private void OnCollapseAll ( object parameter )
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ protected override async void OnExpanded()
3030 await LoadCollectionsAsync ( ) ;
3131 }
3232
33+ public async Task RefreshAsync ( )
34+ {
35+ _hasLoadedCollections = false ;
36+ Children . Clear ( ) ;
37+ Children . Add ( new PlaceholderNode { Name = "Refreshing..." } ) ;
38+ await LoadCollectionsAsync ( ) ;
39+ }
40+
3341 public async Task LoadCollectionsAsync ( )
3442 {
3543 IsLoading = true ;
You can’t perform that action at this time.
0 commit comments