Skip to content

Commit

Permalink
#380 - Show release notes when update is available.
Browse files Browse the repository at this point in the history
Prepare release notes for blazor-v1.16.0.
  • Loading branch information
maraf committed Jun 12, 2021
1 parent 37df1cf commit af0aa57
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Money.Blazor.Host/Components/PwaUpdate.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
<LayoutView Layout="@typeof(Layouts.Layout)">
<Title Icon="download" Main="Great news. We have an update for you" Sub="Update is already installed and one click away" />

<div class="mt-4">
<div class="my-4">
<button class="btn btn-primary" @onclick="(async () => Commands.HandleAsync(new UpdatePwa()))">
Activate the update
</button>
<button class="btn btn-secondary" @onclick="(() => IsUpdateable = false)">
Leave it for the next time
</button>
</div>

@ReleaseNotes
</LayoutView>
}
else
Expand Down
15 changes: 13 additions & 2 deletions src/Money.Blazor.Host/Components/PwaUpdate.razor.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.AspNetCore.Components;
using Money.Events;
using Money.Services;
using Neptuo.Commands;
using Neptuo.Events;
using Neptuo.Events.Handlers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -15,34 +17,43 @@ namespace Money.Components
public partial class PwaUpdate : IDisposable,
IEventHandler<PwaUpdateable>
{
private readonly HttpClient http = new HttpClient();

[Inject]
protected IEventHandlerCollection EventHandlers { get; set; }

[Inject]
protected ICommandDispatcher Commands { get; set; }

[Inject]
protected Navigator Navigator { get; set; }

[Parameter]
public RenderFragment ChildContent { get; set; }

protected bool IsUpdateable { get; set; }
protected MarkupString ReleaseNotes { get; set; }

protected override void OnInitialized()
{
base.OnInitialized();

EventHandlers.Add<PwaUpdateable>(this);
http.BaseAddress = new Uri(Navigator.UrlOrigin());
}

public void Dispose()
{
EventHandlers.Remove<PwaUpdateable>(this);
}

Task IEventHandler<PwaUpdateable>.HandleAsync(PwaUpdateable payload)
async Task IEventHandler<PwaUpdateable>.HandleAsync(PwaUpdateable payload)
{
IsUpdateable = true;

ReleaseNotes = new MarkupString(await http.GetStringAsync("/release-notes.html"));

StateHasChanged();
return Task.CompletedTask;
}
}
}
3 changes: 3 additions & 0 deletions src/Money.Blazor.Host/Services/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public void Dispose()
public string UrlCurrent()
=> manager.Uri;

public string UrlOrigin()
=> manager.BaseUri;

private void OnLocationChanged(object sender, LocationChangedEventArgs e)
{
queryString = null;
Expand Down
22 changes: 22 additions & 0 deletions src/Money.Blazor.Host/wwwroot/release-notes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h3>New features</h3>
<ul>
<li>Expense edit actions in search results.</li>
<li>Small redesign of user info in main navigation bar.</li>
<li>Button for deleting incomes.</li>
<li>Ability to disable mobile bottom navigation.</li>
<li>Use darker blue in theme colors.</li>
<li>Show release notes of available update.</li>
</ul>

<h3>Fixed bugs</h3>
<ul>
<li>Auto select value in amount box</li>
<li>Date for the expense created on the first day of a month.</li>
<li>Currency formatting in income overview for larger amounts.</li>
<li>Horizontal scrolling for trends on small screens.</li>
</ul>

<a target="_blank" href="https://github.com/maraf/Money/releases/blazor-v1.16.0" class="btn btn-light">
<span class="fab fa-github"></span>
See details on GitHub
</a>

0 comments on commit af0aa57

Please sign in to comment.