Skip to content

Commit

Permalink
Fixed nullability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
papafe committed Jul 31, 2023
1 parent cb68a5f commit dc93e6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
10 changes: 10 additions & 0 deletions examples/QuickJournalSync/ViewModels/EntriesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ await realm.WriteAsync(() =>
});
}

[RelayCommand]
public async Task Logout()
{
IsBusy = true;
await RealmService.LogoutAsync();
IsBusy = false;

await Shell.Current.GoToAsync($"//login");
}

private async Task GoToEntry(JournalEntry entry)
{
var navigationParameter = new Dictionary<string, object>
Expand Down
33 changes: 12 additions & 21 deletions examples/QuickJournalSync/ViewModels/LoginViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.Input;
using System.Diagnostics.CodeAnalysis;
using CommunityToolkit.Mvvm.Input;
using QuickJournalSync.Services;

namespace QuickJournalSync.ViewModels
Expand Down Expand Up @@ -28,26 +29,10 @@ public async Task Login()
return;
}

await DoLogin();
}

[RelayCommand]
public async Task SignUp()
{
if (!await VeryifyEmailAndPassword())
{
return;
}

await DoSignup();
}

private async Task DoLogin()
{
try
{
IsBusy = true;
await RealmService.LoginAsync(Email, Password);
await RealmService.LoginAsync(Email!, Password!);
IsBusy = false;
}
catch (Exception ex)
Expand All @@ -60,12 +45,18 @@ private async Task DoLogin()
await GoToMainPage();
}

private async Task DoSignup()
[RelayCommand]
public async Task SignUp()
{
if (!await VeryifyEmailAndPassword())
{
return;
}

try
{
IsBusy = true;
await RealmService.RegisterAsync(Email, Password);
await RealmService.RegisterAsync(Email!, Password!);
IsBusy = false;
}
catch (Exception ex)
Expand All @@ -75,7 +66,7 @@ private async Task DoSignup()
return;
}

await DoLogin();
await Login();
}

private async Task<bool> VeryifyEmailAndPassword()
Expand Down

0 comments on commit dc93e6a

Please sign in to comment.