1
- using CommunityToolkit . Mvvm . Messaging ;
1
+ using CommunityToolkit . Mvvm . DependencyInjection ;
2
+ using CommunityToolkit . Mvvm . Messaging ;
2
3
using Microsoft . UI . Xaml ;
3
4
using Microsoft . UI . Xaml . Controls ;
4
5
using SecureFolderFS . Sdk . Messages ;
6
+ using SecureFolderFS . Sdk . Services ;
5
7
using SecureFolderFS . Sdk . ViewModels . Controls . Sidebar ;
6
8
using SecureFolderFS . Sdk . ViewModels . Vault ;
7
9
using SecureFolderFS . Sdk . ViewModels . Views . Host ;
8
10
using SecureFolderFS . Sdk . ViewModels . Views . Vault ;
11
+ using SecureFolderFS . Shared . Extensions ;
9
12
using SecureFolderFS . UI . Helpers ;
10
13
using System . Linq ;
11
14
using System . Threading . Tasks ;
12
- using SecureFolderFS . Shared . Extensions ;
13
15
14
16
// To learn more about WinUI, the WinUI project structure,
15
17
// and more about our project templates, see: http://aka.ms/winui-project-info.
16
18
17
19
namespace SecureFolderFS . WinUI . UserControls . InterfaceHost
18
20
{
19
- public sealed partial class MainAppHostControl : UserControl , IRecipient < RemoveVaultMessage >
21
+ public sealed partial class MainAppHostControl : UserControl , IRecipient < RemoveVaultMessage > , IRecipient < AddVaultMessage >
20
22
{
23
+ private ISettingsService SettingsService { get ; } = Ioc . Default . GetRequiredService < ISettingsService > ( ) ;
24
+
21
25
public MainAppHostControl ( )
22
26
{
23
27
InitializeComponent ( ) ;
@@ -30,6 +34,16 @@ public void Receive(RemoveVaultMessage message)
30
34
Navigation . ClearContent ( ) ;
31
35
}
32
36
37
+ /// <inheritdoc/>
38
+ public void Receive ( AddVaultMessage message )
39
+ {
40
+ if ( ViewModel . SidebarViewModel . SidebarItems . Count >= Sdk . Constants . Vault . MAX_FREE_AMOUNT_OF_VAULTS
41
+ && ! SettingsService . AppSettings . WasBetaNotificationShown1 )
42
+ {
43
+ BetaTeachingTip . IsOpen = true ;
44
+ }
45
+ }
46
+
33
47
private async Task NavigateToItem ( VaultViewModel vaultViewModel )
34
48
{
35
49
// Find existing target or create new
@@ -43,7 +57,8 @@ private async Task NavigateToItem(VaultViewModel vaultViewModel)
43
57
private async void MainAppHostControl_Loaded ( object sender , RoutedEventArgs e )
44
58
{
45
59
ViewModel . NavigationService . SetupNavigation ( Navigation ) ;
46
- WeakReferenceMessenger . Default . Register ( this ) ;
60
+ WeakReferenceMessenger . Default . Register < RemoveVaultMessage > ( this ) ;
61
+ WeakReferenceMessenger . Default . Register < AddVaultMessage > ( this ) ;
47
62
48
63
await ViewModel . InitAsync ( ) ;
49
64
Sidebar . SelectedItem = ViewModel . SidebarViewModel . SelectedItem ;
@@ -71,6 +86,12 @@ private async void SidebarSearchBox_TextChanged(AutoSuggestBox sender, AutoSugge
71
86
await ViewModel . SidebarViewModel . SearchViewModel . SubmitQuery ( sender . Text ) ;
72
87
}
73
88
89
+ private async void TeachingTip_CloseButtonClick ( TeachingTip sender , object args )
90
+ {
91
+ SettingsService . AppSettings . WasBetaNotificationShown1 = true ;
92
+ await SettingsService . AppSettings . SaveAsync ( ) ;
93
+ }
94
+
74
95
public MainHostViewModel ViewModel
75
96
{
76
97
get => ( MainHostViewModel ) GetValue ( ViewModelProperty ) ;
0 commit comments