fix(loading): update loading checks to use signal() for reactive state management (#727)
This commit is contained in:
+3
-3
@@ -19,19 +19,19 @@
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@if (loading) {
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
{{ t('loading') }}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!loading && changelog.length === 0) {
|
||||
@if (!loading() && changelog.length === 0) {
|
||||
<div class="empty-state">
|
||||
{{ t('empty') }}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!loading && changelog.length > 0) {
|
||||
@if (!loading() && changelog.length > 0) {
|
||||
<div class="changelog-list">
|
||||
@for (release of changelog; track release) {
|
||||
<div class="release-item">
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ describe('VersionChangelogDialogComponent', () => {
|
||||
|
||||
expect(versionService.getChangelog).toHaveBeenCalled();
|
||||
expect(component.changelog).toHaveLength(1);
|
||||
expect(component.loading).toBe(false);
|
||||
expect(component.loading()).toBe(false);
|
||||
});
|
||||
|
||||
it('clears the loading state when the changelog request fails', () => {
|
||||
@@ -58,7 +58,7 @@ describe('VersionChangelogDialogComponent', () => {
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.changelog).toEqual([]);
|
||||
expect(component.loading).toBe(false);
|
||||
expect(component.loading()).toBe(false);
|
||||
});
|
||||
|
||||
it('converts markdown to sanitized HTML and normalizes headings to h3', () => {
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { Component, inject, OnInit, signal } from '@angular/core';
|
||||
import { ReleaseNote, VersionService } from '../../../service/version.service';
|
||||
|
||||
import showdown from 'showdown';
|
||||
@@ -25,7 +25,7 @@ export class VersionChangelogDialogComponent implements OnInit {
|
||||
dialogRef = inject(DynamicDialogRef);
|
||||
|
||||
changelog: ReleaseNote[] = [];
|
||||
loading = true;
|
||||
loading = signal(true);
|
||||
|
||||
private converter = new showdown.Converter({ tables: true, emoji: true });
|
||||
|
||||
@@ -33,10 +33,10 @@ export class VersionChangelogDialogComponent implements OnInit {
|
||||
this.versionService.getChangelog().subscribe({
|
||||
next: (data) => {
|
||||
this.changelog = data;
|
||||
this.loading = false;
|
||||
this.loading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.loading = false;
|
||||
this.loading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user