WHATS_NEW_LAST_SEEN_VERSION setting, seeding, updating

This commit is contained in:
shamoon committed 2026-11-17 23:20:39 -08:00
1 parent 9f57da5193
commit e7a4367540
3 files changed
+101

No files matched your search

+6
View File
@@ -75,6 +75,7 @@ export const SETTINGS_KEYS = {
UPDATE_CHECKING_ENABLED: 'general-settings:update-checking:enabled',
UPDATE_CHECKING_BACKEND_SETTING:
'general-settings:update-checking:backend-setting',
WHATS_NEW_LAST_SEEN_VERSION: 'general-settings:whats-new:last-seen-version',
SAVED_VIEWS_WARN_ON_UNSAVED_CHANGE:
'general-settings:saved-views:warn-on-unsaved-change',
DASHBOARD_VIEWS_VISIBLE_IDS:
@@ -223,6 +224,11 @@ export const SETTINGS: UiSetting[] = [
type: 'string',
default: '',
},
{
key: SETTINGS_KEYS.WHATS_NEW_LAST_SEEN_VERSION,
type: 'string',
default: '',
},
{
key: SETTINGS_KEYS.SAVED_VIEWS_WARN_ON_UNSAVED_CHANGE,
type: 'boolean',
@@ -398,6 +398,60 @@ describe('SettingsService', () => {
expect(req.request.method).toEqual('POST')
})
it('seeds last seen version on first load', () => {
const settings = {
...ui_settings,
user: { ...ui_settings.user, is_superuser: true },
settings: {
...ui_settings.settings,
documentListSize: 50,
update_checking: { enabled: false, backend_setting: 'default' },
},
}
settings.settings['version'] = '3.5.1'
httpTestingController
.expectOne(`${environment.apiBaseUrl}ui_settings/`)
.flush(settings)
const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}ui_settings/`
)
expect(req.request.method).toEqual('POST')
expect(req.request.body.settings.whats_new.last_seen_version).toEqual(
'3.5.1'
)
expect(settingsService.unseenReleasesSince).toBeNull()
})
it('reports unseen releases and marks them seen', () => {
const settings = {
...ui_settings,
user: { ...ui_settings.user, is_superuser: true },
settings: {
...ui_settings.settings,
documentListSize: 50,
update_checking: { enabled: false, backend_setting: 'default' },
},
}
settings.settings['version'] = '3.5.1'
settings.settings['whats_new'] = { last_seen_version: '3.4.2' }
httpTestingController
.expectOne(`${environment.apiBaseUrl}ui_settings/`)
.flush(settings)
httpTestingController.expectNone(`${environment.apiBaseUrl}ui_settings/`)
expect(settingsService.unseenReleasesSince).toEqual('3.4.2')
subscription = settingsService.markReleasesSeen().subscribe()
const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}ui_settings/`
)
expect(req.request.body.settings.whats_new.last_seen_version).toEqual(
'3.5.1'
)
expect(settingsService.unseenReleasesSince).toBeNull()
})
it('updates settings on complete tour', () => {
let req = httpTestingController.expectOne(
`${environment.apiBaseUrl}ui_settings/`
@@ -20,6 +20,7 @@ import {
hexToHsl,
} from 'src/app/utils/color'
import { DEFAULT_APP_TITLE, environment } from 'src/environments/environment'
import { compareVersions } from 'src/app/utils/version'
import { DEFAULT_DISPLAY_FIELDS, DisplayField } from '../data/document'
import { RemoteOCRModeConfig } from '../data/paperless-config'
import { SavedView } from '../data/saved-view'
@@ -384,6 +385,7 @@ export class SettingsService {
uisettings.permissions,
this.currentUser()
)
this.maybeSeedLastSeenVersion()
this.initializeDisplayFields()
})
@@ -713,6 +715,45 @@ export class SettingsService {
return this.settingIsSet(SETTINGS_KEYS.UPDATE_CHECKING_ENABLED)
}
/**
* Record the baseline version for "what's new" tracking.
*/
private maybeSeedLastSeenVersion() {
const currentVersion = this.get(SETTINGS_KEYS.VERSION)
if (
!currentVersion ||
this.get(SETTINGS_KEYS.WHATS_NEW_LAST_SEEN_VERSION) ||
!this.permissionsService.currentUserCan(
PermissionAction.Change,
PermissionType.UISettings
)
)
return
this.set(SETTINGS_KEYS.WHATS_NEW_LAST_SEEN_VERSION, currentVersion)
this.storeSettings()
.pipe(first())
.subscribe({ error: () => {} })
}
/**
* The last version the user saw release notes for, if the running
* version is newer, or null.
*/
public get unseenReleasesSince(): string | null {
const currentVersion = this.get(SETTINGS_KEYS.VERSION)
const lastSeen = this.get(SETTINGS_KEYS.WHATS_NEW_LAST_SEEN_VERSION)
if (!currentVersion || !lastSeen) return null
return compareVersions(currentVersion, lastSeen) > 0 ? lastSeen : null
}
public markReleasesSeen(): Observable<any> {
this.set(
SETTINGS_KEYS.WHATS_NEW_LAST_SEEN_VERSION,
this.get(SETTINGS_KEYS.VERSION)
)
return this.storeSettings()
}
/**
* Offering remote OCR as a choice only makes sense when an engine
* is configured but is not already handling every document.