Skip to content

Commit eefc348

Browse files
committed
refactor: renamings
refactor: cleanup
1 parent c9e3c9d commit eefc348

10 files changed

Lines changed: 123 additions & 151 deletions

File tree

src/ByteSync.Client/ViewModels/Sessions/Inventories/InventoryAnalysisViewModel.cs renamed to src/ByteSync.Client/ViewModels/Sessions/Inventories/InventoryLocalAnalysisViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010

1111
namespace ByteSync.ViewModels.Sessions.Inventories;
1212

13-
public class InventoryAnalysisViewModel : ActivatableViewModelBase
13+
public class InventoryLocalAnalysisViewModel : ActivatableViewModelBase
1414
{
1515
private readonly IInventoryService _inventoryService = null!;
1616
private readonly IThemeService _themeService = null!;
1717

18-
public InventoryAnalysisViewModel()
18+
public InventoryLocalAnalysisViewModel()
1919
{
2020
}
2121

22-
public InventoryAnalysisViewModel(IInventoryService inventoryService)
22+
public InventoryLocalAnalysisViewModel(IInventoryService inventoryService)
2323
{
2424
_inventoryService = inventoryService;
2525

2626
this.WhenActivated(HandleActivation);
2727
}
2828

29-
public InventoryAnalysisViewModel(IInventoryService inventoryService, IThemeService themeService)
29+
public InventoryLocalAnalysisViewModel(IInventoryService inventoryService, IThemeService themeService)
3030
: this(inventoryService)
3131
{
3232
_themeService = themeService;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Reactive.Disposables;
2+
using System.Reactive.Linq;
3+
using ByteSync.Business.Inventories;
4+
using ByteSync.Interfaces.Controls.Inventories;
5+
using ReactiveUI;
6+
using ReactiveUI.Fody.Helpers;
7+
8+
namespace ByteSync.ViewModels.Sessions.Inventories;
9+
10+
public class InventoryMainViewModel : ActivatableViewModelBase
11+
{
12+
private readonly IInventoryService _inventoryService;
13+
14+
public InventoryMainViewModel()
15+
{
16+
}
17+
18+
public InventoryMainViewModel(InventoryMainStatusViewModel inventoryMainStatusViewModel,
19+
InventoryIdentificationViewModel inventoryIdentificationViewModel,
20+
InventoryLocalAnalysisViewModel inventoryLocalAnalysisViewModel,
21+
InventoryBeforeStartViewModel inventoryBeforeStartViewModel,
22+
IInventoryService inventoryService)
23+
{
24+
_inventoryService = inventoryService;
25+
26+
InventoryMainStatusViewModel = inventoryMainStatusViewModel;
27+
InventoryIdentificationViewModel = inventoryIdentificationViewModel;
28+
InventoryLocalAnalysisViewModel = inventoryLocalAnalysisViewModel;
29+
InventoryBeforeStartViewModel = inventoryBeforeStartViewModel;
30+
31+
InventoryProcessData = _inventoryService.InventoryProcessData;
32+
33+
this.WhenActivated(HandleActivation);
34+
}
35+
36+
private void HandleActivation(CompositeDisposable disposables)
37+
{
38+
_inventoryService.InventoryProcessData.MainStatus.DistinctUntilChanged()
39+
.Select(status => status is not InventoryTaskStatus.Pending)
40+
.ToPropertyEx(this, x => x.HasLocalInventoryStarted)
41+
.DisposeWith(disposables);
42+
}
43+
44+
public extern bool HasLocalInventoryStarted { [ObservableAsProperty] get; }
45+
46+
[Reactive]
47+
public InventoryProcessData InventoryProcessData { get; set; }
48+
49+
public InventoryMainStatusViewModel InventoryMainStatusViewModel { get; set; }
50+
51+
public InventoryIdentificationViewModel InventoryIdentificationViewModel { get; set; }
52+
53+
public InventoryLocalAnalysisViewModel InventoryLocalAnalysisViewModel { get; set; }
54+
55+
public InventoryBeforeStartViewModel InventoryBeforeStartViewModel { get; set; }
56+
}

src/ByteSync.Client/ViewModels/Sessions/Inventories/InventoryProcessViewModel.cs

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/ByteSync.Client/ViewModels/Sessions/SessionMainViewModel.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
namespace ByteSync.ViewModels.Sessions;
2121

22-
public class SessionMainViewModel : ViewModelBase, IRoutableViewModel, IActivatableViewModel
22+
public class SessionMainViewModel : ViewModelBase, IRoutableViewModel, IActivatableViewModel
2323
{
2424
public string? UrlPathSegment { get; }
25-
25+
2626
public IScreen HostScreen { get; }
27-
27+
2828
public ViewModelActivator Activator { get; }
2929

3030
private readonly ISessionService _sessionService;
@@ -33,22 +33,22 @@ public class SessionMainViewModel : ViewModelBase, IRoutableViewModel, IActivata
3333
private readonly IDataNodeViewModelFactory _dataNodeViewModelFactory;
3434
private readonly IDataNodeRepository _dataNodeRepository;
3535
private readonly ISessionMemberRepository _sessionMemberRepository;
36-
37-
public SessionMainViewModel(IScreen screen, ISessionService sessionService, InventoryProcessViewModel inventoryProcessViewModel,
38-
ComparisonResultViewModel comparisonResultViewModel, CurrentCloudSessionViewModel currentCloudSessionViewModel,
39-
SynchronizationMainViewModel synchronizationMainViewModel, IDataNodeViewModelFactory dataNodeViewModelFactory,
36+
37+
public SessionMainViewModel(IScreen screen, ISessionService sessionService, InventoryMainViewModel inventoryMainViewModel,
38+
ComparisonResultViewModel comparisonResultViewModel, CurrentCloudSessionViewModel currentCloudSessionViewModel,
39+
SynchronizationMainViewModel synchronizationMainViewModel, IDataNodeViewModelFactory dataNodeViewModelFactory,
4040
IDataNodeRepository dataNodeRepository, ISessionMemberRepository sessionMemberRepository)
4141
{
4242
HostScreen = screen;
4343
Activator = new ViewModelActivator();
44-
44+
4545
_sessionService = sessionService;
4646
_dataNodeViewModelFactory = dataNodeViewModelFactory;
4747
_dataNodeRepository = dataNodeRepository;
4848
_sessionMemberRepository = sessionMemberRepository;
4949

5050
CloudSessionManagement = currentCloudSessionViewModel;
51-
InventoryProcess = inventoryProcessViewModel;
51+
InventoryMain = inventoryMainViewModel;
5252
ComparisonResult = comparisonResultViewModel;
5353
SynchronizationProcess = synchronizationMainViewModel;
5454

@@ -61,7 +61,7 @@ public SessionMainViewModel(IScreen screen, ISessionService sessionService, Inve
6161
.Bind(out _dataNodes)
6262
.DisposeMany()
6363
.Subscribe();
64-
64+
6565
this.WhenActivated(disposables =>
6666
{
6767
dataNodesCache.DisposeWith(disposables);
@@ -71,7 +71,7 @@ public SessionMainViewModel(IScreen screen, ISessionService sessionService, Inve
7171
.Select(x => x == SessionModes.Cloud)
7272
.ToPropertyEx(this, x => x.IsCloudSessionMode)
7373
.DisposeWith(disposables);
74-
74+
7575
_sessionService.SessionObservable
7676
.Where(x => x != null)
7777
.Select(x => x is CloudSession)
@@ -80,10 +80,10 @@ public SessionMainViewModel(IScreen screen, ISessionService sessionService, Inve
8080

8181
_sessionService.SessionStatusObservable.CombineLatest(_sessionMemberRepository.SortedSessionMembersObservable)
8282
.Select(s => (s.First == SessionStatus.Preparation && s.Second.Count > 0)
83-
|| (s.First == SessionStatus.Inventory
84-
|| s.First == SessionStatus.Comparison
85-
|| s.First == SessionStatus.Synchronization)
86-
)
83+
|| (s.First == SessionStatus.Inventory
84+
|| s.First == SessionStatus.Comparison
85+
|| s.First == SessionStatus.Synchronization)
86+
)
8787
.ObserveOn(RxApp.MainThreadScheduler)
8888
.ToPropertyEx(this, x => x.IsInventoryVisible)
8989
.DisposeWith(disposables);
@@ -103,7 +103,7 @@ public SessionMainViewModel(IScreen screen, ISessionService sessionService, Inve
103103
}
104104

105105
public ReadOnlyObservableCollection<DataNodeViewModel> DataNodes => _dataNodes;
106-
106+
107107
[Reactive]
108108
public ViewModelBase? CloudSessionManagement { get; set; }
109109

@@ -113,19 +113,19 @@ public SessionMainViewModel(IScreen screen, ISessionService sessionService, Inve
113113
public extern bool IsCloudSessionMode { [ObservableAsProperty] get; }
114114

115115
public extern bool IsCloudSession { [ObservableAsProperty] get; }
116-
116+
117117
public extern bool IsInventoryVisible { [ObservableAsProperty] get; }
118-
118+
119119
public extern bool IsComparisonVisible { [ObservableAsProperty] get; }
120120

121121
public extern bool IsSynchronizationVisible { [ObservableAsProperty] get; }
122122

123123
[Reactive]
124-
public ViewModelBase InventoryProcess { get; set; }
125-
124+
public ViewModelBase InventoryMain { get; set; }
125+
126126
[Reactive]
127127
public ComparisonResultViewModel ComparisonResult { get; set; }
128-
128+
129129
[Reactive]
130130
public ViewModelBase SynchronizationProcess { get; set; }
131131
}

src/ByteSync.Client/Views/Sessions/Inventories/InventoryAnalysisView.axaml renamed to src/ByteSync.Client/Views/Sessions/Inventories/InventoryLocalAnalysisView.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
xmlns:inventories="clr-namespace:ByteSync.ViewModels.Sessions.Inventories"
77
xmlns:localizations="clr-namespace:ByteSync.Services.Localizations"
88
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
9-
x:Class="ByteSync.Views.Sessions.Inventories.InventoryAnalysisView">
9+
x:Class="ByteSync.Views.Sessions.Inventories.InventoryLocalAnalysisView">
1010

1111
<Design.DataContext>
12-
<inventories:InventoryAnalysisViewModel />
12+
<inventories:InventoryLocalAnalysisViewModel />
1313
</Design.DataContext>
1414

1515
<StackPanel Orientation="Vertical" VerticalAlignment="Center">

src/ByteSync.Client/Views/Sessions/Inventories/InventoryAnalysisView.axaml.cs renamed to src/ByteSync.Client/Views/Sessions/Inventories/InventoryLocalAnalysisView.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace ByteSync.Views.Sessions.Inventories;
55

6-
public partial class InventoryAnalysisView : ReactiveUserControl<InventoryAnalysisViewModel>
6+
public partial class InventoryLocalAnalysisView : ReactiveUserControl<InventoryLocalAnalysisViewModel>
77
{
8-
public InventoryAnalysisView()
8+
public InventoryLocalAnalysisView()
99
{
1010
InitializeComponent();
1111
}

src/ByteSync.Client/Views/Sessions/Inventories/InventoryProcessView.axaml renamed to src/ByteSync.Client/Views/Sessions/Inventories/InventoryMainView.axaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
xmlns:inventories="clr-namespace:ByteSync.ViewModels.Sessions.Inventories"
66
xmlns:local="clr-namespace:ByteSync.Views.Sessions.Inventories"
77
mc:Ignorable="d" d:DesignWidth="1400" d:DesignHeight="450"
8-
x:Class="ByteSync.Views.Sessions.Inventories.InventoryProcessView">
9-
8+
x:Class="ByteSync.Views.Sessions.Inventories.InventoryMainView">
9+
1010
<Design.DataContext>
11-
<inventories:InventoryProcessViewModel />
11+
<inventories:InventoryMainViewModel />
1212
</Design.DataContext>
13-
13+
1414
<Grid Margin="6">
1515
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
1616

17-
<!--Before HasLocalInventoryStarted-->
17+
<!--Before HasLocalInventoryStarted-->
1818
<Grid IsVisible="{Binding !HasLocalInventoryStarted}">
19-
<local:InventoryBeforeStartView DataContext="{Binding InventoryBeforeStartViewModel}"/>
19+
<local:InventoryBeforeStartView DataContext="{Binding InventoryBeforeStartViewModel}" />
2020
</Grid>
2121

2222

23-
<!--Details, after HasLocalInventoryStarted-->
23+
<!--Details, after HasLocalInventoryStarted-->
2424
<Grid IsVisible="{Binding HasLocalInventoryStarted}">
2525
<Grid.ColumnDefinitions>
2626
<ColumnDefinition Width="*" MaxWidth="600"></ColumnDefinition>
@@ -29,15 +29,15 @@
2929
</Grid.ColumnDefinitions>
3030

3131
<!-- Main Status -->
32-
<local:InventoryMainStatusView Grid.Column="0" DataContext="{Binding InventoryMainStatusViewModel}"/>
32+
<local:InventoryMainStatusView Grid.Column="0" DataContext="{Binding InventoryMainStatusViewModel}" />
3333

3434
<!-- Identification -->
35-
<local:InventoryIdentificationView Grid.Column="1" DataContext="{Binding InventoryIdentificationViewModel}"/>
35+
<local:InventoryIdentificationView Grid.Column="1" DataContext="{Binding InventoryIdentificationViewModel}" />
3636

3737
<!-- Analysis -->
38-
<local:InventoryAnalysisView Grid.Column="2" DataContext="{Binding InventoryAnalysisViewModel}"/>
38+
<local:InventoryLocalAnalysisView Grid.Column="2" DataContext="{Binding InventoryLocalAnalysisViewModel}" />
3939
</Grid>
4040

4141
</StackPanel>
4242
</Grid>
43-
</UserControl>
43+
</UserControl>

src/ByteSync.Client/Views/Sessions/Inventories/InventoryProcessView.axaml.cs renamed to src/ByteSync.Client/Views/Sessions/Inventories/InventoryMainView.axaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
namespace ByteSync.Views.Sessions.Inventories;
66

7-
public partial class InventoryProcessView : ReactiveUserControl<InventoryProcessViewModel>
7+
public partial class InventoryMainView : ReactiveUserControl<InventoryMainViewModel>
88
{
9-
public InventoryProcessView()
9+
public InventoryMainView()
1010
{
1111
InitializeComponent();
1212

1313
this.WhenActivated(disposables => { });
14-
1514
}
1615
}

0 commit comments

Comments
 (0)