Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Antoine-Soucy committed Apr 18, 2024
1 parent 7416dd2 commit 224f487
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions doc/ForcedUpdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The forced update feature is for when you want to force the user to update the app.
You could use this, for example, when the backend changes and you do not want the users to still use the old API.

To force an update, we suscribe to the UpdateRequired Event from the UpdateRequiredservice in the coreStartup.
To force an update, we suscribe to the `UpdateRequired` Event from the `UpdateRequiredservice` in the `CoreStartup`.

```cs
private void SuscribeToRequiredUpdate(IServiceProvider services)
Expand All @@ -27,4 +27,4 @@ To force an update, we suscribe to the UpdateRequired Event from the UpdateRequi
}
```

This will direct the user to a page from which they cannot navigate back. The page will contain a button that leads them to the appropriate page for updating the app, with the links defined in AppSettings.
This will direct the user to a page from which they cannot navigate back. The page will contain a button that leads them to the appropriate page for updating the app, with the links defined in `AppSettings`.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public interface IUpdateRequiredService : IDisposable
/// <summary>
/// Event that is raised when the application needs to be updated.
/// </summary>
/// <remarks> This is using a plain event with no arguments because this is an event that should only be raised once,
/// and requires the application to be relaunched after being updated.</remarks>
event EventHandler UpdateRequired;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
namespace ApplicationTemplate.Business;

/// <summary>
/// Mock implementation of the <see cref="IUpdateRequiredService"/>.
/// Implementation of the <see cref="IUpdateRequiredService"/>.
/// </summary>
public sealed class UpdateRequiredServiceMock : IUpdateRequiredService
public sealed class UpdateRequiredService : IUpdateRequiredService
{
private readonly IDisposable _subscription;

/// <summary>
/// Initializes a new instance of the <see cref="UpdateRequiredServiceMock"/> class.
/// Initializes a new instance of the <see cref="UpdateRequiredService"/> class.
/// </summary>
/// <param name="minimumVersionReposiory"> A repository that contains an observable we can use to update the app. </param>
public UpdateRequiredServiceMock(IMinimumVersionReposiory minimumVersionReposiory)
public UpdateRequiredService(IMinimumVersionReposiory minimumVersionReposiory)
{
_subscription = minimumVersionReposiory.MinimumVersionObservable
.Subscribe(_ => UpdateRequired?.Invoke(this, EventArgs.Empty));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static IServiceCollection AddAppServices(this IServiceCollection services
.AddSingleton<IDadJokesService, DadJokesService>()
.AddSingleton<IAuthenticationService, AuthenticationService>()
.AddSingleton<IUserProfileService, UserProfileService>()
.AddSingleton<IUpdateRequiredService, UpdateRequiredServiceMock>()
.AddSingleton<IUpdateRequiredService, UpdateRequiredService>()
.AddSingleton<DiagnosticsCountersService>();
}
}
4 changes: 2 additions & 2 deletions src/app/ApplicationTemplate.Presentation/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"ApplicationStoreUrls": {
// TODO: Update the URLs with the actual URLs.
"IOS": "https://apps.apple.com/us/app/duolingo-language-lessons/id570060128",
"Android": "https://play.google.com/store/apps/details?id=com.duolingo",
"IOS": "https://apps.apple.com/us/app/uno-calculator/id1464736591",
"Android": "https://play.google.com/store/apps/details?id=uno.platform.calculator",
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public sealed class ForceUpdatesShould : FunctionalTestBase
/// <summary>
/// Tests that the force update page is shown when the update required event is raised.
/// </summary>
/// <returns> A task. </returns>
[Fact]
public async Task RedirectTheAppToForceUpdatePage()
{
Expand All @@ -29,16 +28,13 @@ public async Task RedirectTheAppToForceUpdatePage()
// Waits for the navigation to be completed, we need the StartWith in case the navigation already finished before we started observing.
await sectionNavigator.ObserveCurrentState().StartWith(sectionNavigator.State).Where(x => x.LastRequestState != NavigatorRequestState.Processing).FirstAsync();

minimumVersionReposiory.Dispose();

// Assert
ActiveViewModel.Should().BeOfType<ForcedUpdatePageViewModel>();
}

/// <summary>
/// Tests that you are still in the forced update page even after you pressed on the back button.
/// </summary>
/// <returns> A task. </returns>
[Fact]
public async Task DisableTheBackButton()
{
Expand All @@ -58,8 +54,6 @@ public async Task DisableTheBackButton()

await sectionNavigator.ObserveCurrentState().StartWith(sectionNavigator.State).Where(x => x.LastRequestState != NavigatorRequestState.Processing).FirstAsync();

minimumVersionReposiory.Dispose();

// Assert
ActiveViewModel.Should().BeOfType<ForcedUpdatePageViewModel>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class FunctionalTestBase : IAsyncLifetime
{
private readonly ITestOutputHelper _output;
private readonly CoreStartup _coreStartup;
private readonly BackButtonSource _backButtonSource = new();
private readonly FunctionalTestBackButtonSource _backButtonSource = new();
private readonly Lazy<ShellViewModel> _shellViewModel = new Lazy<ShellViewModel>(() => new ShellViewModel());

/// <summary>
Expand Down Expand Up @@ -195,9 +195,9 @@ async Task IAsyncLifetime.DisposeAsync()
_coreStartup.Dispose();
}

private sealed class BackButtonSource : IBackButtonSource
private sealed class FunctionalTestBackButtonSource : IBackButtonSource
{
public string Name => "Test";
public string Name => "FunctionalTestBackButtonSource";

public event BackRequestedEventHandler BackRequested;

Expand Down

0 comments on commit 224f487

Please sign in to comment.