diff --git a/src-ui/src/app/components/dashboard/dashboard.component.spec.ts b/src-ui/src/app/components/dashboard/dashboard.component.spec.ts index 23228d247..3f36b8f0c 100644 --- a/src-ui/src/app/components/dashboard/dashboard.component.spec.ts +++ b/src-ui/src/app/components/dashboard/dashboard.component.spec.ts @@ -194,14 +194,4 @@ describe('DashboardComponent', () => { >) expect(toastSpy).toHaveBeenCalled() }) - - it('should get custom app title', () => { - const title = 'FooBar' - expect(component.subtitle).toContain('Paperless-ngx') - expect(component.subtitle).not.toContain(title) - jest.spyOn(settingsService, 'get').mockImplementation((key) => { - if (key === SETTINGS_KEYS.APP_TITLE) return title - }) - expect(component.subtitle).toContain(title) - }) }) diff --git a/src-ui/src/app/components/dashboard/dashboard.component.ts b/src-ui/src/app/components/dashboard/dashboard.component.ts index dd69ffb5d..906cc775a 100644 --- a/src-ui/src/app/components/dashboard/dashboard.component.ts +++ b/src-ui/src/app/components/dashboard/dashboard.component.ts @@ -5,13 +5,13 @@ import { ComponentWithPermissions } from '../with-permissions/with-permissions.c import { TourService } from 'ngx-ui-tour-ng-bootstrap' import { SavedView } from 'src/app/data/saved-view' import { ToastService } from 'src/app/services/toast.service' -import { SETTINGS_KEYS } from 'src/app/data/ui-settings' import { CdkDragDrop, CdkDragEnd, CdkDragStart, moveItemInArray, } from '@angular/cdk/drag-drop' +import { environment } from 'src/environments/environment' @Component({ selector: 'pngx-dashboard', @@ -34,13 +34,10 @@ export class DashboardComponent extends ComponentWithPermissions { } get subtitle() { - const appTitle = this.settingsService.get(SETTINGS_KEYS.APP_TITLE)?.length - ? this.settingsService.get(SETTINGS_KEYS.APP_TITLE) - : 'Paperless-ngx' if (this.settingsService.displayName) { - return $localize`Hello ${this.settingsService.displayName}, welcome to ${appTitle}` + return $localize`Hello ${this.settingsService.displayName}, welcome to ${environment.appTitle}` } else { - return $localize`Welcome to ${appTitle}` + return $localize`Welcome to ${environment.appTitle}` } } diff --git a/src-ui/src/app/services/settings.service.spec.ts b/src-ui/src/app/services/settings.service.spec.ts index 0c148cec2..ff0a9837b 100644 --- a/src-ui/src/app/services/settings.service.spec.ts +++ b/src-ui/src/app/services/settings.service.spec.ts @@ -301,4 +301,16 @@ describe('SettingsService', () => { .expectOne(`${environment.apiBaseUrl}ui_settings/`) .flush(ui_settings) }) + + it('should update environment app title if set', () => { + const settings = Object.assign({}, ui_settings) + settings.settings['app_title'] = 'FooBar' + const req = httpTestingController.expectOne( + `${environment.apiBaseUrl}ui_settings/` + ) + req.flush(settings) + expect(environment.appTitle).toEqual('FooBar') + // post for migrate + httpTestingController.expectOne(`${environment.apiBaseUrl}ui_settings/`) + }) }) diff --git a/src-ui/src/app/services/settings.service.ts b/src-ui/src/app/services/settings.service.ts index 9f8560322..4bbeb1dde 100644 --- a/src-ui/src/app/services/settings.service.ts +++ b/src-ui/src/app/services/settings.service.ts @@ -270,6 +270,9 @@ export class SettingsService { first(), tap((uisettings) => { Object.assign(this.settings, uisettings.settings) + if (this.get(SETTINGS_KEYS.APP_TITLE)?.length) { + environment.appTitle = this.get(SETTINGS_KEYS.APP_TITLE) + } this.maybeMigrateSettings() // to update lang cookie if (this.settings['language']?.length)