Skip to content

Commit

Permalink
Fix local connection
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJMN committed Oct 23, 2023
1 parent 591ba4a commit 81caff7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal class ConnectionsRepository : IConnectionsRepository
private readonly SourceCache<IFileSystemConnection, string> connectionsSource = new(x => x.Name);
private readonly ConfigurationStore store;


public ConnectionsRepository(IEnumerable<IFileSystemConnection> connections, Maybe<ILogger> logger, ConfigurationStore store)
{
this.store = store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ public static IConfiguration ToEditable(IFileSystemConnection connection)
{
return connection switch
{
LocalFileSystemConnection local => new LocalConfigurationViewModel(local.Name),
SeaweedFileSystemConnection seaweedFileFileSystemConnection => new SeaweedConfigurationViewModel(seaweedFileFileSystemConnection.Name)
{
Address = seaweedFileFileSystemConnection.Uri.ToString()
},
AndroidFileSystemConnection localFileSystemConnection => new LocalConfigurationViewModel(localFileSystemConnection.Name),
AndroidFileSystemConnection localFileSystemConnection => new AndroidConfigurationViewModel(localFileSystemConnection.Name),
SftpFileSystemConnection sftp => new SftpConfigurationViewModel(sftp.Name)
{
Host = sftp.Parameters.Host,
Expand All @@ -94,7 +95,7 @@ public static IFileSystemConnection ToConnection(IConfiguration currentConfigura
return currentConfiguration switch
{
SeaweedConfigurationViewModel swfs => new SeaweedFileSystemConnection(swfs.Name, new Uri(swfs.Address), Maybe<ILogger>.None),
LocalConfigurationViewModel local => new AndroidFileSystemConnection(local.Name),
LocalConfigurationViewModel local => new LocalFileSystemConnection(local.Name),
SftpConfigurationViewModel sftp => new SftpFileSystemConnection(
sftp.Name,
new SftpConnectionParameters(sftp.Host,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
x:DataType="synchronization:SyncronizationSectionViewModel">
<DockPanel>
<Button DockPanel.Dock="Top" Margin="8" Content="Add session…" Command="{Binding AddSession}" />
<TabControl ItemsSource="{Binding Sessions}">
<TabControl ItemsSource="{Binding Sessions}" SelectedItem="{Binding SelectedSession}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Description}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using CSharpFunctionalExtensions;
using DynamicData;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Serilog;
using Zafiro.Avalonia.Dialogs;
using Zafiro.Avalonia.FileExplorer.Clipboard;
Expand Down Expand Up @@ -38,10 +39,17 @@ public SyncronizationSectionViewModel(IConnectionsRepository connectionsReposito
this.transferManager = transferManager;
this.logger = logger;
AddSession = ReactiveCommand.CreateFromTask(OnAddSession);
AddSession.Values().Subscribe(session => sessions.Add(session));
AddSession.Values().Subscribe(session =>
{
sessions.Add(session);
SelectedSession = session;
});
sessions.Connect().Bind(out sessionsCollection).Subscribe();
}

[Reactive]
public GranularSessionViewModel SelectedSession { get; set; }

public ReactiveCommand<Unit, Maybe<GranularSessionViewModel>> AddSession { get; set; }

public ReadOnlyObservableCollection<GranularSessionViewModel> Sessions => sessionsCollection;
Expand Down

0 comments on commit 81caff7

Please sign in to comment.