Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public SelectPageViewModelDesigner()
public ICollectionView ItemsView { get; }
public IRepositoryItemViewModel SelectedItem { get; set; }
public RepositoryModel Repository { get; }
public ReactiveCommand<Unit, Unit> Refresh { get; }

public void Initialize(IConnection connection)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class RepositorySelectViewModel : ViewModelBase, IRepositorySelectViewMod
ICollectionView itemsView;
ObservableAsPropertyHelper<RepositoryModel> repository;
IRepositoryItemViewModel selectedItem;
static bool firstLoad = true;

[ImportingConstructor]
public RepositorySelectViewModel(IRepositoryCloneService service, IGitHubContextService gitHubContextService)
Expand All @@ -57,6 +58,12 @@ public RepositorySelectViewModel(IRepositoryCloneService service, IGitHubContext
.ToProperty(this, x => x.Repository);

this.WhenAnyValue(x => x.Filter).Subscribe(_ => ItemsView?.Refresh());

Refresh = ReactiveCommand.CreateFromTask(async () =>
{
await this.LoadItems(true);
return Unit.Default;
});
}

public Exception Error
Expand Down Expand Up @@ -101,6 +108,8 @@ public IRepositoryItemViewModel SelectedItem
set => this.RaiseAndSetIfChanged(ref selectedItem, value);
}

public ReactiveCommand<Unit, Unit> Refresh { get; }

public RepositoryModel Repository => repository.Value;

public void Initialize(IConnection connection)
Expand All @@ -113,7 +122,8 @@ public void Initialize(IConnection connection)

public async Task Activate()
{
await this.LoadItems(true);
await this.LoadItems(firstLoad);
firstLoad = false;
}

static string GroupName(KeyValuePair<string, IReadOnlyList<RepositoryListItemModel>> group, int max)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface IRepositorySelectViewModel : IRepositoryCloneTabViewModel
IReadOnlyList<IRepositoryItemViewModel> Items { get; }
ICollectionView ItemsView { get; }
IRepositoryItemViewModel SelectedItem { get; set; }
ReactiveCommand<Unit, Unit> Refresh { get; }

void Initialize(IConnection connection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
</UserControl.Resources>

<DockPanel>
<ghfvs:PromptTextBox DockPanel.Dock="Top"
Margin="0,4"
PromptText="Search or enter a URL"
Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged, Delay=300}"/>

<DockPanel DockPanel.Dock="Top" Margin="0,4">
<Button DockPanel.Dock="Right" Command="{Binding Refresh}">Refresh</Button>
<ghfvs:PromptTextBox PromptText="Search or enter a URL"
Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged, Delay=300}"/>
</DockPanel>
<Grid>
<ListView BorderThickness="0"
ItemsSource="{Binding ItemsView}"
Expand Down