Skip to content

Commit

Permalink
Finished the overhaul to the License info screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
majora2007 committed Jan 4, 2025
1 parent 3f1f42a commit 1091caf
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions API.Tests/API.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="21.1.7" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="21.1.7" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="21.2.1" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="21.2.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions API/API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<PackageReference Include="Hangfire.InMemory" Version="1.0.0" />
<PackageReference Include="Hangfire.MaximumConcurrentExecutions" Version="1.1.0" />
<PackageReference Include="Hangfire.Storage.SQLite" Version="0.4.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Include="MarkdownDeep.NET.Core" Version="1.5.0.4" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.17" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
Expand Down Expand Up @@ -104,10 +104,10 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
<PackageReference Include="System.IO.Abstractions" Version="21.1.7" />
<PackageReference Include="System.IO.Abstractions" Version="21.2.1" />
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
<PackageReference Include="VersOne.Epub" Version="3.3.2" />
<PackageReference Include="YamlDotNet" Version="16.2.1" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion API/Services/Plus/LicenseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public async Task<bool> ResetLicense(string license, string email)
.WithKavitaPlusHeaders(encryptedLicense.Value)
.GetJsonAsync<LicenseInfoDto>();

// This indicates a mismatch on installid or no active subscription
// This indicates a mismatch on installId or no active subscription
if (response == null) return null;

// Ensure that current version is within the 3 version limit. Don't count Nightly releases or Hotfixes
Expand Down
4 changes: 3 additions & 1 deletion API/Services/TaskScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ public async Task ScheduleKavitaPlusTasks()
RecurringJob.AddOrUpdate(CheckScrobblingTokensId, () => _scrobblingService.CheckExternalAccessTokens(),
Cron.Daily, RecurringJobOptions);
BackgroundJob.Enqueue(() => _scrobblingService.CheckExternalAccessTokens()); // We also kick off an immediate check on startup
RecurringJob.AddOrUpdate(LicenseCheckId, () => _licenseService.HasActiveLicense(true),

// Get the License Info (and cache it) on first load. This will internally cache the Github releases for the Version Service
RecurringJob.AddOrUpdate(LicenseCheckId, () => _licenseService.GetLicenseInfo(true),
LicenseService.Cron, RecurringJobOptions);

// KavitaPlus Scrobbling (every 4 hours)
Expand Down
15 changes: 7 additions & 8 deletions API/Services/Tasks/VersionUpdaterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,15 @@ public async Task<IList<UpdateNotificationDto>> GetAllReleases(int count = 0)
return updateDtos;
}

private async Task<IList<UpdateNotificationDto>?> TryGetCachedReleases()
private static async Task<IList<UpdateNotificationDto>?> TryGetCachedReleases()
{
if (File.Exists(_cacheFilePath))
if (!File.Exists(_cacheFilePath)) return null;

var fileInfo = new FileInfo(_cacheFilePath);
if (DateTime.UtcNow - fileInfo.LastWriteTimeUtc <= CacheDuration)
{
var fileInfo = new FileInfo(_cacheFilePath);
if (DateTime.UtcNow - fileInfo.LastWriteTimeUtc <= CacheDuration)
{
var cachedData = await File.ReadAllTextAsync(_cacheFilePath);
return System.Text.Json.JsonSerializer.Deserialize<IList<UpdateNotificationDto>>(cachedData);
}
var cachedData = await File.ReadAllTextAsync(_cacheFilePath);
return System.Text.Json.JsonSerializer.Deserialize<IList<UpdateNotificationDto>>(cachedData);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion UI/Web/src/app/_models/kavitaplus/license-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export interface LicenseInfo {
expirationDate: string;
isActive: boolean;
isCancelled: boolean;
isVersionValid: boolean;
isValidVersion: boolean;
registeredEmail: string;
totalMonthsSubbed: number;
hasLicense: boolean;
Expand Down
8 changes: 4 additions & 4 deletions UI/Web/src/app/admin/license/license.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<form [formGroup]="formGroup">
<div class="mt-2">
<app-setting-item [title]="t('title')" (editMode)="updateEditMode($event)" [isEditMode]="!isViewMode" [showEdit]="licenseInfo?.hasLicense || false">
<app-setting-item [title]="t('title')" (editMode)="updateEditMode($event)" [isEditMode]="!isViewMode" [showEdit]="hasLicense">
<ng-template #titleExtra>
<button class="btn btn-icon btn-sm" (click)="loadLicenseInfo(true)">
@if (isChecking) {
Expand Down Expand Up @@ -41,7 +41,7 @@
</i>
}
}
@if (hasLicense && !licenseInfo) {
@if (!isChecking && hasLicense && !licenseInfo) {
<div><span class="error">{{t('license-mismatch')}}</span></div>
}

Expand Down Expand Up @@ -140,8 +140,8 @@ <h3 class="container-fluid">{{t('info-title')}}</h3>
<div class="mb-2 col-md-6 col-sm-12">
<app-setting-item [canEdit]="false" [showEdit]="false" [title]="t('supported-version-label')">
<ng-template #view>
<i class="fas {{licenseInfo.isVersionValid ? 'fa-check-circle' : 'fa-circle-xmark error'}}">
<span class="visually-hidden">{{isVersionValid ? t('valid') : t('invalid')}]</span>
<i class="fas {{licenseInfo.isValidVersion ? 'fa-check-circle' : 'fa-circle-xmark error'}}">
<span class="visually-hidden">{{isValidVersion ? t('valid') : t('invalid')}]</span>
</i>
</ng-template>
</app-setting-item>
Expand Down

0 comments on commit 1091caf

Please sign in to comment.