1
- using System . Reactive ;
2
1
using System . Reactive . Linq ;
3
2
using Avalonia . Media ;
4
3
using Avalonia . Media . Imaging ;
7
6
using NexusMods . Abstractions . UI ;
8
7
using NexusMods . App . UI . Controls . Navigation ;
9
8
using NexusMods . App . UI . WorkspaceSystem ;
9
+ using R3 ;
10
10
using ReactiveUI ;
11
11
using ReactiveUI . Fody . Helpers ;
12
+ using Observable = R3 . Observable ;
13
+ using ReactiveCommand = ReactiveUI . ReactiveCommand ;
14
+ using Unit = System . Reactive . Unit ;
12
15
13
16
namespace NexusMods . App . UI . Controls . TopBar ;
14
17
@@ -23,28 +26,33 @@ public class TopBarDesignViewModel : AViewModel<ITopBarViewModel>, ITopBarViewMo
23
26
24
27
[ Reactive ] public IAddPanelDropDownViewModel AddPanelDropDownViewModel { get ; set ; } = new AddPanelDropDownDesignViewModel ( ) ;
25
28
26
- public ReactiveCommand < NavigationInformation , Unit > OpenSettingsCommand => ReactiveCommand . Create < NavigationInformation , Unit > ( _ => Unit . Default ) ;
29
+ public ReactiveUI . ReactiveCommand < NavigationInformation , Unit > OpenSettingsCommand => ReactiveCommand . Create < NavigationInformation , Unit > ( _ => Unit . Default ) ;
27
30
28
- public ReactiveCommand < NavigationInformation , Unit > ViewChangelogCommand => ReactiveCommand . Create < NavigationInformation , Unit > ( _ => Unit . Default ) ;
29
- public ReactiveCommand < Unit , Unit > ViewAppLogsCommand => Initializers . DisabledReactiveCommand ;
30
- public ReactiveCommand < Unit , Unit > ShowWelcomeMessageCommand => Initializers . EnabledReactiveCommand ;
31
- public ReactiveCommand < Unit , Unit > OpenDiscordCommand => ReactiveCommand . Create ( ( ) => { } ) ;
32
- public ReactiveCommand < Unit , Unit > OpenForumsCommand => ReactiveCommand . Create ( ( ) => { } ) ;
33
- public ReactiveCommand < Unit , Unit > OpenGitHubCommand => ReactiveCommand . Create ( ( ) => { } ) ;
34
- public ReactiveCommand < Unit , Unit > OpenStatusPageCommand => ReactiveCommand . Create ( ( ) => { } ) ;
31
+ public ReactiveUI . ReactiveCommand < NavigationInformation , Unit > ViewChangelogCommand => ReactiveCommand . Create < NavigationInformation , Unit > ( _ => Unit . Default ) ;
32
+ public ReactiveUI . ReactiveCommand < Unit , Unit > ViewAppLogsCommand => Initializers . DisabledReactiveCommand ;
33
+ public ReactiveUI . ReactiveCommand < Unit , Unit > ShowWelcomeMessageCommand => Initializers . EnabledReactiveCommand ;
34
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenDiscordCommand => ReactiveCommand . Create ( ( ) => { } ) ;
35
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenForumsCommand => ReactiveCommand . Create ( ( ) => { } ) ;
36
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenGitHubCommand => ReactiveCommand . Create ( ( ) => { } ) ;
37
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenStatusPageCommand => ReactiveCommand . Create ( ( ) => { } ) ;
35
38
36
- public ReactiveCommand < Unit , Unit > LoginCommand { get ; set ; }
37
- public ReactiveCommand < Unit , Unit > LogoutCommand { get ; set ; }
38
- public ReactiveCommand < Unit , Unit > OpenNexusModsProfileCommand => Initializers . DisabledReactiveCommand ;
39
- public ReactiveCommand < Unit , Unit > OpenNexusModsPremiumCommand => Initializers . EnabledReactiveCommand ;
40
- public ReactiveCommand < Unit , Unit > OpenNexusModsAccountSettingsCommand => Initializers . DisabledReactiveCommand ;
39
+ public R3 . ReactiveCommand < R3 . Unit , R3 . Unit > LoginCommand { get ; set ; }
40
+ public ReactiveUI . ReactiveCommand < Unit , Unit > LogoutCommand { get ; set ; }
41
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenNexusModsProfileCommand => Initializers . DisabledReactiveCommand ;
42
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenNexusModsPremiumCommand => Initializers . EnabledReactiveCommand ;
43
+ public ReactiveUI . ReactiveCommand < Unit , Unit > OpenNexusModsAccountSettingsCommand => Initializers . DisabledReactiveCommand ;
41
44
42
45
public IPanelTabViewModel ? SelectedTab { get ; set ; }
43
46
44
47
public TopBarDesignViewModel ( )
45
48
{
46
49
LogoutCommand = ReactiveCommand . Create ( ToggleLogin , this . WhenAnyValue ( vm => vm . IsLoggedIn ) ) ;
47
- LoginCommand = ReactiveCommand . Create ( ToggleLogin , this . WhenAnyValue ( vm => vm . IsLoggedIn ) . Select ( x => ! x ) ) ;
50
+ LoginCommand = ReactiveCommandExtensions . ToReactiveCommand < R3 . Unit , R3 . Unit > ( Observable . ToObservable ( this . WhenAnyValue ( vm => vm . IsLoggedIn ) . Select ( x => ! x ) ) , convert :
51
+ _ =>
52
+ {
53
+ ToggleLogin ( ) ;
54
+ return R3 . Unit . Default ;
55
+ } ) ;
48
56
}
49
57
50
58
private void ToggleLogin ( )
0 commit comments