windows app display last update now correctly

This commit is contained in:
Tobias Wohlleben 2024-09-12 14:54:00 +02:00
parent 836fcb3f4d
commit 51212f9354
6 changed files with 22 additions and 3 deletions

View File

@ -0,0 +1 @@
dotnet publish -c Release -r android-arm64 -p:PackageFormat=Apk -f net8.0-android34.0 --sc true

View File

@ -46,6 +46,10 @@
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.26100.0</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.26100.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android34.0|AnyCPU'">
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- App Icon --> <!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" /> <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
@ -76,4 +80,8 @@
<ProjectReference Include="..\RBLNews.Shared\RBLNews.Shared.csproj" /> <ProjectReference Include="..\RBLNews.Shared\RBLNews.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="IaC\" />
</ItemGroup>
</Project> </Project>

View File

@ -14,7 +14,7 @@
<div class="top-row ps-3 navbar navbar-dark"> <div class="top-row ps-3 navbar navbar-dark">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<Icon Name="IconName.InfoCircle" class="me-2"></Icon>Letztes Update @this.FeedDataService.Feeds?.LastUpdate.ToString("dd.MM.yyyy HH:mm") <Icon Name="IconName.InfoCircle" class="me-2"></Icon>Letztes Update @FeedDataService.Feeds?.LastUpdate.ToString("dd.MM.yyyy HH:mm")
</div> </div>
</div> </div>
</div> </div>
@ -49,4 +49,10 @@
@code { @code {
[Inject] [Inject]
private IFeedDataService FeedDataService { get; set; } private IFeedDataService FeedDataService { get; set; }
protected override void OnInitialized()
{
FeedDataService.DataChanged= () => StateHasChanged();
}
} }

View File

@ -55,7 +55,6 @@ else
protected async override Task OnInitializedAsync() protected async override Task OnInitializedAsync()
{ {
await FeedDataService.LoadFeeds(); await FeedDataService.LoadFeeds();
StateHasChanged();
} }
private string GetRssSourceName(RssFeedSources source) private string GetRssSourceName(RssFeedSources source)

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor"> <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>

View File

@ -7,6 +7,8 @@ namespace RBLNews.Shared.Services
public interface IFeedDataService public interface IFeedDataService
{ {
public RssVM Feeds { get; } public RssVM Feeds { get; }
public Action DataChanged { get; set; }
Task LoadFeeds(); Task LoadFeeds();
} }
@ -16,10 +18,13 @@ namespace RBLNews.Shared.Services
private static readonly HttpClient httpClient = new(); private static readonly HttpClient httpClient = new();
public RssVM Feeds { get; private set; } public RssVM Feeds { get; private set; }
public Action DataChanged { get; set; }
public async Task LoadFeeds() public async Task LoadFeeds()
{ {
Feeds = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds") ?? new RssVM(); Feeds = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds") ?? new RssVM();
DataChanged.Invoke();
} }
} }
} }