|
>(PatchDB)
- .watch$('packageData')
- .pipe(
- map(pkgs =>
- Object.entries(pkgs).reduce<
- Record>
- >(
- (acc, [id, val]) =>
- isInstalled(val) || isUpdating(val)
- ? { ...acc, [id]: val }
- : acc,
- {},
- ),
- ),
- ),
+ localPkgs: inject(LocalPackagesService),
errors: this.marketplaceService.requestErrors$,
}),
)
diff --git a/web/projects/ui/src/app/services/api/mock-patch.ts b/web/projects/ui/src/app/services/api/mock-patch.ts
index 287ad5814..25cb03402 100644
--- a/web/projects/ui/src/app/services/api/mock-patch.ts
+++ b/web/projects/ui/src/app/services/api/mock-patch.ts
@@ -194,7 +194,7 @@ export const mockPatchData: DataModel = {
staticServers: null,
},
},
- unreadNotificationCount: 4,
+ unreadNotificationCount: 5,
// password is asdfasdf
passwordHash:
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
diff --git a/web/projects/ui/src/app/services/badge.service.ts b/web/projects/ui/src/app/services/badge.service.ts
index 42380743d..7627c52ef 100644
--- a/web/projects/ui/src/app/services/badge.service.ts
+++ b/web/projects/ui/src/app/services/badge.service.ts
@@ -1,23 +1,11 @@
import { inject, Injectable } from '@angular/core'
import { PatchDB } from 'patch-db-client'
-import {
- combineLatest,
- EMPTY,
- filter,
- first,
- map,
- Observable,
- pairwise,
- shareReplay,
- startWith,
- switchMap,
-} from 'rxjs'
-import { ConnectionService } from 'src/app/services/connection.service'
-import { OSService } from 'src/app/services/os.service'
+import { combineLatest, EMPTY, map, Observable, shareReplay } from 'rxjs'
+import { LocalPackagesService } from 'src/app/services/local-packages.service'
import { MarketplaceService } from 'src/app/services/marketplace.service'
import { NotificationService } from 'src/app/services/notification.service'
+import { OSService } from 'src/app/services/os.service'
import { DataModel } from 'src/app/services/patch-db/data-model'
-import { getManifest } from 'src/app/utils/get-package-data'
import { FilterUpdatesPipe } from '../routes/portal/routes/updates/filter-updates.pipe'
@Injectable({
@@ -35,32 +23,9 @@ export class BadgeService {
private readonly marketplaceService = inject(MarketplaceService)
private readonly filterUpdatesPipe = inject(FilterUpdatesPipe)
- private readonly local$ = inject(ConnectionService).pipe(
- filter(Boolean),
- switchMap(() => this.patch.watch$('packageData').pipe(first())),
- switchMap(outer =>
- this.patch.watch$('packageData').pipe(
- pairwise(),
- filter(([prev, curr]) =>
- Object.values(prev).some(p => {
- const { id } = getManifest(p)
-
- return (
- !curr[id] ||
- (p.stateInfo.installingInfo &&
- !curr[id]?.stateInfo.installingInfo)
- )
- }),
- ),
- map(([_, curr]) => curr),
- startWith(outer),
- ),
- ),
- )
-
private readonly updates$ = combineLatest([
this.marketplaceService.marketplace$,
- this.local$,
+ inject(LocalPackagesService),
]).pipe(
map(
([marketplace, local]) =>
diff --git a/web/projects/ui/src/app/services/local-packages.service.ts b/web/projects/ui/src/app/services/local-packages.service.ts
new file mode 100644
index 000000000..31bde46c2
--- /dev/null
+++ b/web/projects/ui/src/app/services/local-packages.service.ts
@@ -0,0 +1,34 @@
+import { inject, Injectable } from '@angular/core'
+import { PatchDB } from 'patch-db-client'
+import { map, Observable, shareReplay } from 'rxjs'
+import {
+ DataModel,
+ InstalledState,
+ PackageDataEntry,
+ UpdatingState,
+} from 'src/app/services/patch-db/data-model'
+import { isInstalled, isUpdating } from 'src/app/utils/get-package-data'
+
+@Injectable({
+ providedIn: 'root',
+})
+export class LocalPackagesService extends Observable<
+ Record>
+> {
+ private readonly stream$ = inject>(PatchDB)
+ .watch$('packageData')
+ .pipe(
+ map(pkgs =>
+ Object.entries(pkgs).reduce(
+ (acc, [id, val]) =>
+ isInstalled(val) || isUpdating(val) ? { ...acc, [id]: val } : acc,
+ {},
+ ),
+ ),
+ shareReplay({ bufferSize: 1, refCount: true }),
+ )
+
+ constructor() {
+ super(subscriber => this.stream$.subscribe(subscriber))
+ }
+}
diff --git a/web/projects/ui/src/app/services/notification.service.ts b/web/projects/ui/src/app/services/notification.service.ts
index eb5a39641..edb109b6f 100644
--- a/web/projects/ui/src/app/services/notification.service.ts
+++ b/web/projects/ui/src/app/services/notification.service.ts
@@ -95,21 +95,26 @@ export class NotificationService {
viewModal(notification: ServerNotification, full = false) {
const { data, createdAt, code, title, message } = notification
- const label = code === 1 ? 'Backup Report' : (title as i18nKey)
- const component = code === 1 ? REPORT : MARKDOWN
- const content = code === 1 ? data : of(data)
-
this.markSeen([notification])
- this.dialogs
- .openComponent(full ? message : component, {
- label,
- data: {
- content,
- timestamp: createdAt,
- },
- size: code === 1 ? 'm' : 'l',
- })
- .subscribe()
+
+ if (code === 1) {
+ // Backup Report
+ this.dialogs
+ .openComponent(full ? message : REPORT, {
+ label: 'Backup Report',
+ data: { content: data, createdAt },
+ })
+ .subscribe()
+ } else {
+ // Markdown viewer
+ this.dialogs
+ .openComponent(full ? message : MARKDOWN, {
+ label: title as i18nKey,
+ data: of(data),
+ size: 'l',
+ })
+ .subscribe()
+ }
}
private async updateCount(toAdjust: number) {
diff --git a/web/projects/ui/src/styles.scss b/web/projects/ui/src/styles.scss
index a1c3500a2..757b8a6b1 100644
--- a/web/projects/ui/src/styles.scss
+++ b/web/projects/ui/src/styles.scss
@@ -25,7 +25,6 @@ hr {
:root {
--bumper: 0.375rem;
- --tui-font-text: 'Proxima Nova', system-ui;
}
.g-page {
|