Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(notices): a release's notes show to whoever dismissed them on its prerelease

Mauricedaaa6c425d68
diff --git a/server/src/nest/system-notices/system-notices.service.ts b/server/src/nest/system-notices/system-notices.service.ts
index a37441857..d172acb22 100644
--- a/server/src/nest/system-notices/system-notices.service.ts
+++ b/server/src/nest/system-notices/system-notices.service.ts
@@ -143,14 +143,18 @@ export class SystemNoticesService {
managed: this.env.isManaged(),
settingFlag: (key: string) => settingFlags.get(key) ?? false,
};
- const appVer = semver.coerce(currentAppVersion)?.version ?? '0.0.0';
+ // Full versions, the prerelease part included: a dismissal on 5.0.0-pre.2 is older
+ // than 5.0.0, so whoever tried a prerelease still gets the notes of the release.
+ const fullVersion = (v: string | null | undefined) =>
+ semver.valid(v ?? '') ?? semver.coerce(v ?? '')?.version ?? '0.0.0';
+ const appVer = fullVersion(currentAppVersion);
const isStillDismissed = (n: SystemNotice): boolean => {
if (!dismissals.has(n.id)) return false;
if (n.recurring === 'per-version') {
// Re-show once the running app version moves past the version it was last dismissed at,
// so a per-version notice surfaces again on each install/upgrade.
- const dismissedVer = semver.coerce(dismissals.get(n.id) ?? '0.0.0')?.version ?? '0.0.0';
+ const dismissedVer = fullVersion(dismissals.get(n.id));
return semver.gte(dismissedVer, appVer);
}
return true; // default: permanent one-time dismissal
diff --git a/server/tests/unit/nest/system-notices.service.test.ts b/server/tests/unit/nest/system-notices.service.test.ts
index 6b1be994b..ece403658 100644
--- a/server/tests/unit/nest/system-notices.service.test.ts
+++ b/server/tests/unit/nest/system-notices.service.test.ts
@@ -162,6 +162,18 @@ describe('SystemNoticesService (Plan 3f Task 6)', () => {
).not.toContain('sn-test-release');
});
+ it('SN4b — a dismissal on a prerelease of the running version is older, so the notice of the release shows', async () => {
+ // Tried 5.0.0-pre.2, now on 5.0.0: the prerelease part must not be dropped.
+ const prerelease = makeService({
+ listForUser: [{ notice_id: 'sn-test-release', dismissed_app_version: `${getCurrentAppVersion()}-pre.2` }],
+ });
+ expect(
+ (await prerelease.svc.getActiveFor(BASE_USER.id, new Set(['release']), getCurrentAppVersion())).map(
+ (n) => n.id,
+ ),
+ ).toContain('sn-test-release');
+ });
+
it('a permanently-dismissed (non-recurring) notice never returns', async () => {
const { svc } = makeService({ listForUser: [{ notice_id: 'sn-test-generic', dismissed_app_version: null }] });
expect((await svc.getActiveFor(BASE_USER.id)).map((n) => n.id)).not.toContain('sn-test-generic');