From 7f681c9e81414568579d45b7b51a356660d72448 Mon Sep 17 00:00:00 2001 From: Joshua Oosthuizen Date: Fri, 27 Nov 2026 15:35:38 +0200 Subject: [PATCH] Events 3.7.2 + Website 1.6.1: no duplicate events after a reseed; "Events site" in the header A reseed gives every event a new id without listing the old ones in the feed's `deleted`, and consumers only fetched ?updatedSince= after the first sync, so the old copies stayed beside the new ones. - Both: the 15-minute feed poll and "Sync now" fetch the whole list and drop copies that aren't in it; the fetch after event.changed stays incremental. - Events set-demo.js keeps FeedEntry and marks its live entries removed, resets the links' lastGoodAt, then publishes the new feed, sends event.changed and fetches the linked products' events back in. - Website loadDemo lists the old published events in FeedRemoval and sends event.changed after publishing. - Website header: links to the church's other sites read "Events site" with an external-link icon, not a second "Events". Checked: Website backend tests (133), Events backend tests (802), both typechecks, Website frontend build. set-demo.js not run end to end (no local database). Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 13 ++++++ apps/events/CHANGELOG.md | 17 ++++++++ apps/events/WHATS-NEW.md | 5 +++ apps/events/backend/DEMO_DATA.md | 6 ++- apps/events/backend/package.json | 2 +- apps/events/backend/scripts/set-demo.js | 42 +++++++++++++++++++ apps/events/backend/src/feed/sync.ts | 11 +++-- .../src/v2/resources/linkedProducts.ts | 2 +- .../backend/tests/linkedProducts.test.js | 10 +++++ apps/events/frontend/package.json | 2 +- apps/events/package.json | 2 +- apps/website/CHANGELOG.md | 23 ++++++++++ apps/website/WHATS-NEW.md | 8 ++++ apps/website/backend/package.json | 2 +- apps/website/backend/src/admin/routes.ts | 2 +- apps/website/backend/src/demo/demoChurch.ts | 13 +++++- apps/website/backend/src/feed/feed.ts | 14 ++++--- apps/website/backend/tests/feed.test.ts | 13 ++++++ apps/website/backend/tests/site.test.ts | 12 ++++++ apps/website/frontend/package.json | 2 +- apps/website/frontend/src/site/Header.tsx | 14 +++++-- docs/EVENTS-2.4-PLAN.md | 5 +++ docs/VERSIONS.md | 12 ++++-- package-lock.json | 8 ++-- 24 files changed, 211 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd7b077..d29b8c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …). +## events@3.7.2 + website@1.6.1 - 2026-11-27 + +Events shown on the other product's site no longer show twice after a reseed, and the Website's +header marks the link to the Events site. Details in each app's CHANGELOG. No migrations. + +- **Both:** the 15-minute event-feed poll and "Sync now" fetch the whole list and drop copies that + aren't in it, so events a sibling lost without listing them in `deleted` (a reseed, a restore) + can't stay beside the new ones. The fetch after an `event.changed` stays incremental. +- **Events 3.7.2:** new demo data (`set-demo.js`) lists the old events as removed in the feed, + publishes the new ones and tells the Website at once, and fetches the Website's events back in. +- **Website 1.6.1:** loading a demo lists the old events as removed and tells Events; the header + shows "Events site" with an external-link icon instead of a second "Events". + ## website@1.6.0 - 2026-11-27 The demo church has real photos, and photos in small frames load at their size. Details in diff --git a/apps/events/CHANGELOG.md b/apps/events/CHANGELOG.md index 8730d73..c2af9d1 100644 --- a/apps/events/CHANGELOG.md +++ b/apps/events/CHANGELOG.md @@ -5,6 +5,23 @@ All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project follows [Semantic Versioning](https://semver.org/). +## [3.7.2] - 2026-11-27 + +No migrations, no new settings. + +### Fixed + +- **New demo data no longer leaves the old events on the church's Website.** `set-demo.js` + truncated `FeedEntry`, so the feed never listed the old events in `deleted` and the Website kept + showing them beside the new ones. Now `FeedEntry` is kept and its live entries are marked removed, + the links' `lastGoodAt` is reset (their copies were truncated, so the next fetch is a full one), + and after loading the script publishes the new events, sends `event.changed` to the linked + products and fetches their events back in (`demoFeed`), so the Website's next page load is right. +- **Copies of a linked product's events can't stay forever.** The 15-minute `feed-sync` job and + "Sync now" fetch the whole list and drop copies that aren't in it (`syncLink(link, now, { full: true })`), + so events a sibling lost without listing them in `deleted` (a reseed, a restore) go within 15 + minutes. The fetch after an `event.changed` still asks only for what changed. + ## [3.7.1] - 2026-11-26 No migrations, no new settings. diff --git a/apps/events/WHATS-NEW.md b/apps/events/WHATS-NEW.md index afd2503..cda3a27 100644 --- a/apps/events/WHATS-NEW.md +++ b/apps/events/WHATS-NEW.md @@ -12,6 +12,11 @@ Write for church admins, not developers: no environment variables, endpoints or developer log is CHANGELOG.md. A tagged version without a section here shows "No details given". --> +## 3.7.2 + +- **Fixed: events from your Church Website could show twice** after the website's content was + replaced. Cross Events now checks the full list every 15 minutes and removes events that are gone. + ## 3.7.1 - **Connecting to your new Church Website works straight away**, so its events page can show your diff --git a/apps/events/backend/DEMO_DATA.md b/apps/events/backend/DEMO_DATA.md index d79c0d3..7599540 100644 --- a/apps/events/backend/DEMO_DATA.md +++ b/apps/events/backend/DEMO_DATA.md @@ -63,9 +63,13 @@ previous demo and creates it again. | The admin account, including its login history, trusted devices and 2FA | Every other user | | Migration history | Registrations, payments, tickets, scans, coupons, waitlists, consents, cabins, feedback, analytics, audit log | | Uploaded files on disk (`public/uploads`) | Queued scheduled emails/WhatsApps (`data/scheduled-emails.json`) | +| Links to the church's other products (Accounts, the Website) | Copies of the linked products' events (fetched again straight away) | +| The event feed's history: the old events are listed as removed | | The wipe and the new data are written in one database transaction. If that fails, -nothing changes. The past events' cashups run straight afterwards, through the same +nothing changes. Since 3.7.2 the script then publishes the new events in the event feed and +tells the linked products (the Church Website), so their next page load shows the new events +and not the old ones, and fetches the linked products' events back in. The past events' cashups run straight afterwards, through the same code as the cashup screen. If one of those fails, re-run the script. --- diff --git a/apps/events/backend/package.json b/apps/events/backend/package.json index 48143c0..7b6c6d3 100644 --- a/apps/events/backend/package.json +++ b/apps/events/backend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/events-backend", - "version": "3.7.1", + "version": "3.7.2", "description": "Event Management System Backend", "main": "src/index.js", "scripts": { diff --git a/apps/events/backend/scripts/set-demo.js b/apps/events/backend/scripts/set-demo.js index 934bf56..a795e92 100644 --- a/apps/events/backend/scripts/set-demo.js +++ b/apps/events/backend/scripts/set-demo.js @@ -79,6 +79,9 @@ const KEEP_TABLES = new Set([ // 3.5.0: the links to the church's other products (Accounts above all: in Accounts mode, without // its link nobody can sign in). Their feeds are data and go. 'ProductLink', 'LinkNonce', + // 3.7.2: what the feed last published. Its live entries are marked removed instead (clearData), + // so linked products are told the old events are gone, not left showing them beside the new. + 'FeedEntry', ]); const SCHEDULED_EMAILS_PATH = path.resolve(__dirname, '../data/scheduled-emails.json'); @@ -1823,6 +1826,10 @@ async function clearData(tx) { await tx.$executeRawUnsafe(`UPDATE "User" SET ${[...new Set(userRefs.map(r => `"${r.column}" = NULL`))].join(', ')}`); for (const table of deleteInstead) await tx.$executeRawUnsafe(`DELETE FROM "${table}"`); } + // 3.7.2: every event the feed published goes into its `deleted` list, and the copies of linked + // products' events (truncated above) are fetched again in full. + await tx.feedEntry.updateMany({ where: { removedAt: null }, data: { removedAt: new Date() } }); + await tx.productLink.updateMany({ data: { lastGoodAt: null } }); // Their password resets, 2FA codes and trusted devices go with them (onDelete: Cascade). const { count } = await tx.user.deleteMany({ where: { id: { not: admin.id } } }); await tx.securityEvent.deleteMany({ where: { OR: [{ userId: null }, { userId: { not: admin.id } }] } }); @@ -1911,6 +1918,7 @@ async function main() { clearScheduledEmails(); const pastFinancials = await closePastEvents(); const accounts = await demoAccounts(oldSubs); + const feed = await demoFeed(); const count = (model, where = () => true) => (rows[model] || []).filter(where).length; console.log(`\nCleared ${cleared.tables} tables and ${cleared.users} users.`); @@ -1963,6 +1971,40 @@ async function main() { if (accounts.removed) console.log(`The ${accounts.removed} demo people of the last demo were removed from the church's Accounts.`); console.log(`Sign-in goes through the church's Accounts: ${accounts.moved} demo people have church accounts with that password${accounts.refused.length ? ` (${accounts.refused.length} couldn't: ${accounts.refused.map(r => `${r.email} ${r.reason}`).join('; ')})` : ''}.`); } + if (feed && feed.links) console.log(`Connected products: ${feed.told} of ${feed.links} told the events changed${feed.failed ? `; ${feed.failed} couldn't be fetched from (the next poll catches up)` : ''}.`); +} + +/** + * The backend's own code: the compiled code (dist/) on a server, the TypeScript through tsx in + * development. With dist/, its database client is a second one, disconnected at the end. + */ +function backendModule(rel) { + const dist = path.join(__dirname, '..', 'dist', `${rel}.js`); + if (fs.existsSync(dist)) { + accountsDb = require(path.join(__dirname, '..', 'dist', 'config', 'db')); + return require(dist); + } + require('tsx/cjs'); + return require(`../src/${rel}.ts`); +} + +/** + * 3.7.2: the new events published in the feed straight away, linked products (the Website) told, + * so their next page load shows the new events without the old (marked removed in clearData), and + * their events fetched back in. Never fails the demo: the jobs catch up within 15 minutes. + */ +async function demoFeed() { + try { + const { refreshAndNotify } = backendModule('feed/notify'); + const { syncAll } = backendModule('feed/sync'); + const { told } = await refreshAndNotify(new Date()); + const synced = await syncAll(new Date()); + const links = await prisma.productLink.count(); + return { links, told, failed: synced.failed }; + } catch (e) { + console.warn(`[warn] The feed couldn't be refreshed now (${e.message}); the backend's feed jobs catch up within 15 minutes.`); + return null; + } } /** diff --git a/apps/events/backend/src/feed/sync.ts b/apps/events/backend/src/feed/sync.ts index f6b64b5..02f7bc3 100644 --- a/apps/events/backend/src/feed/sync.ts +++ b/apps/events/backend/src/feed/sync.ts @@ -23,9 +23,14 @@ type Link = { installId: string; product: string; url: string; showEvents: boole export type SyncResult = { installId: string; ok: boolean; imported?: number; deleted?: number; rejected?: number; skipped?: number; error?: string }; -export async function syncLink(link: Link, now = new Date()): Promise { +/** + * `full` asks for the whole list and drops copies no longer in it: a sibling that loses events + * without listing them in `deleted` (a reseed, a restore) would otherwise leave stale copies + * beside the new ones for good. + */ +export async function syncLink(link: Link, now = new Date(), { full = false }: { full?: boolean } = {}): Promise { if (!link.showEvents) return { installId: link.installId, ok: true, imported: 0, deleted: 0 }; - const since = link.lastGoodAt ? new Date(link.lastGoodAt.getTime() - OVERLAP_MS) : null; + const since = !full && link.lastGoodAt ? new Date(link.lastGoodAt.getTime() - OVERLAP_MS) : null; try { const url = await siblingUrl(link.url, FEED_PATHS.events, since ? { updatedSince: since.toISOString() } : {}); const parsed = parseEventFeed(await callSibling(url, { method: 'GET' })); @@ -62,7 +67,7 @@ async function upsert(linkId: string, e: CrosscodeEvent) { export async function syncAll(now = new Date()): Promise<{ links: number; failed: number }> { const links: Link[] = await prisma.productLink.findMany({ where: { showEvents: true } }); let failed = 0; - for (const link of links) if (!(await syncLink(link, now)).ok) failed++; + for (const link of links) if (!(await syncLink(link, now, { full: true })).ok) failed++; return { links: links.length, failed }; } diff --git a/apps/events/backend/src/v2/resources/linkedProducts.ts b/apps/events/backend/src/v2/resources/linkedProducts.ts index 4af19c6..3f51054 100644 --- a/apps/events/backend/src/v2/resources/linkedProducts.ts +++ b/apps/events/backend/src/v2/resources/linkedProducts.ts @@ -207,7 +207,7 @@ export const syncNow = defineRoute({ async handler({ params }) { const link = await prisma.productLink.findUnique({ where: { installId: params.installId } }); if (!link) throw notFound('That connected product'); - await syncLink(link); + await syncLink(link, new Date(), { full: true }); return { data: await overview() }; }, }); diff --git a/apps/events/backend/tests/linkedProducts.test.js b/apps/events/backend/tests/linkedProducts.test.js index 1c7dbe4..1794f78 100644 --- a/apps/events/backend/tests/linkedProducts.test.js +++ b/apps/events/backend/tests/linkedProducts.test.js @@ -399,6 +399,16 @@ describe('events from a linked product', () => { expect(String(global.fetch.mock.calls[0][0])).toContain('updatedSince='); }); + test('a full fetch (the poll) drops copies of events the source lost without saying (a reseed)', async () => { + db.t.productLink.set(WEBSITE_ID, { ...linkRow(), lastGoodAt: NOW }); + db.t.importedEvent.set('website:old', { key: 'website:old', linkId: WEBSITE_ID }); + const e = sample(); + answer(feedOf([e])); + await syncLink(db.t.productLink.get(WEBSITE_ID), NOW, { full: true }); + expect(String(global.fetch.mock.calls[0][0])).not.toContain('updatedSince='); + expect([...db.t.importedEvent.keys()]).toEqual([`website:${e.id}`]); + }); + test('deleted events go; never re-published in this site\'s own feed', async () => { db.t.productLink.set(WEBSITE_ID, { ...linkRow(), lastGoodAt: NOW }); const e = sample(); diff --git a/apps/events/frontend/package.json b/apps/events/frontend/package.json index 5d02bea..4b483c5 100644 --- a/apps/events/frontend/package.json +++ b/apps/events/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/events-frontend", - "version": "3.7.1", + "version": "3.7.2", "private": true, "scripts": { "dev": "next dev", diff --git a/apps/events/package.json b/apps/events/package.json index ad8fc5e..b532ad2 100644 --- a/apps/events/package.json +++ b/apps/events/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/events", - "version": "3.7.1", + "version": "3.7.2", "main": "index.js", "scripts": { "dev:backend": "cd backend && npm run dev", diff --git a/apps/website/CHANGELOG.md b/apps/website/CHANGELOG.md index 23b07ad..07bbb7a 100644 --- a/apps/website/CHANGELOG.md +++ b/apps/website/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog — Church Website +## [1.6.1] — 2026-11-27 + +No migration, no new environment settings. + +### Fixed + +- **Events from Cross Events no longer show twice after Events is reseeded.** After the first + fetch, the Website only asked for what changed (`?updatedSince=`) and dropped a copy only when + the feed listed it in `deleted`. A reseed (or a restore) gives every event a new id without + listing the old ones, so the old copies stayed beside the new. The 15-minute poll and "Sync now" + now fetch the whole list and drop copies that aren't in it (`syncLink(…, { full: true })`); the + fetch after an `event.changed` still asks only for what changed. +- **Loading a demo (`npm run demo`, `crosscode demo … website`) tells Cross Events.** The old + published events go into the feed's `deleted` (`FeedRemoval`) and linked products get an + `event.changed`, so Events drops its copies straight away instead of showing them beside the + new ones. + +### Changed + +- **The header's links to the church's other sites say so:** "Events site" with an external-link + icon (title "Our separate site"), instead of "Events", which looked like a second link to this + site's own Events page. + ## [1.6.0] — 2026-11-27 No migration, no new environment settings. diff --git a/apps/website/WHATS-NEW.md b/apps/website/WHATS-NEW.md index 8da31b9..ad5a3f3 100644 --- a/apps/website/WHATS-NEW.md +++ b/apps/website/WHATS-NEW.md @@ -3,6 +3,14 @@ What each version changes for the church, in plain language (read by the Hub like Cross Events' WHATS-NEW.md; a section shows once its version is tagged). +## 1.6.1 + +- **The link to your Cross Events site is easier to tell apart** in your website's menu: it now + says "Events site" with a small arrow icon, so visitors don't mistake it for your website's own + Events page. +- **Fixed: events from Cross Events could show twice** after the Events site's data was replaced. + Your website now checks the full list every 15 minutes and removes events that are gone. + ## 1.6.0 - **Photos load faster on phones.** Photos in small frames (the collage at the top of the diff --git a/apps/website/backend/package.json b/apps/website/backend/package.json index 8d30d33..a0c4d9f 100644 --- a/apps/website/backend/package.json +++ b/apps/website/backend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/website-backend", - "version": "1.6.0", + "version": "1.6.1", "description": "Church Website: the public site's content API, the admin API, publishing and uploads", "private": true, "type": "module", diff --git a/apps/website/backend/src/admin/routes.ts b/apps/website/backend/src/admin/routes.ts index 79904bc..e626800 100644 --- a/apps/website/backend/src/admin/routes.ts +++ b/apps/website/backend/src/admin/routes.ts @@ -179,7 +179,7 @@ export function adminRouter(ctx: Ctx) { r.post('/links/:id/sync', editor, handle(async (req) => { const link = await ctx.db.productLink.findUnique({ where: { installId: param(req, 'id') } }); if (!link) throw new ApiError(404, 'NOT_LINKED', "That product isn't connected."); - return syncLink(ctx, link); + return syncLink(ctx, link, { full: true }); })); r.put('/feed', editor, json, handle(async (req) => { await ctx.settings.set('feed_publish', req.body?.publish === false ? 'false' : 'true'); diff --git a/apps/website/backend/src/demo/demoChurch.ts b/apps/website/backend/src/demo/demoChurch.ts index 5f70e05..aa851dc 100644 --- a/apps/website/backend/src/demo/demoChurch.ts +++ b/apps/website/backend/src/demo/demoChurch.ts @@ -18,6 +18,7 @@ import { fileURLToPath } from 'node:url'; import { CHURCH_SCHEMA, WEBSITE_TEMPLATES, type agent, type Church, type WebsiteTemplate } from '@crosscode/contracts'; import type { Ctx } from '../context.js'; import { churchProfile } from '../church/profile.js'; +import { markRemoved, notifyLinks } from '../feed/feed.js'; import type { SectionData } from '../site/sections.js'; import { publish } from '../site/snapshot.js'; import { TEMPLATE_HEADERS, TEMPLATE_VARIANTS, SECTION_TYPES, defaultDesign, type SiteDesign } from '../site/variants.js'; @@ -248,6 +249,10 @@ export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDe // The site icon is a setting, so its picture stays; every other picture goes with the content. const faviconId = classic ? null : await ctx.settings.get('favicon_media_id'); + // 1.6.1: the published events that go are listed in the feed's `deleted`, so linked products + // (Cross Events) drop their copies instead of showing them beside the new ones. + const gone = (await db.simpleEvent.findMany({ where: { publishedAt: { not: null } }, select: { id: true } })).map((e) => e.id); + for (const id of gone) await markRemoved(ctx, id, true); for (const m of ['section', 'page', 'ministry', 'leader', 'message', 'messageSeries', 'simpleEvent', 'siteVersion', 'siteDesign', 'slugHistory', 'previewLink'] as const) { await (db[m] as unknown as { deleteMany: (a?: object) => Promise }).deleteMany({}); } @@ -324,9 +329,13 @@ export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDe await db.message.create({ data: { slug, title, date: new Date(now.getTime() - ago * day), source: 'youtube', mediaUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ', thumbnailUrl, speaker, passage, seriesId: series.id, publishedAt: now } }); } n = 0; + const made: string[] = []; for (const [slug, title, inDays, description] of seed.events) { const startsAt = new Date(Math.floor((now.getTime() + inDays * day) / day) * day + 8 * 3600e3); - await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: t(seed.venue), description: t(description), imageId: img[`event${n++}`] ?? null, publishedAt: now } }); + made.push((await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: t(seed.venue), description: t(description), imageId: img[`event${n++}`] ?? null, publishedAt: now } })).id); } - return publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, classic ? `Demo church on ${seed.template}` : `Demo: ${seed.label}`); + const version = await publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, classic ? `Demo church on ${seed.template}` : `Demo: ${seed.label}`); + // Linked products fetch the feed now, not at their next poll (one try; the poll catches up). + await notifyLinks(ctx, [...gone, ...made]).catch(() => {}); + return version; } diff --git a/apps/website/backend/src/feed/feed.ts b/apps/website/backend/src/feed/feed.ts index 8168cbd..4f2e90d 100644 --- a/apps/website/backend/src/feed/feed.ts +++ b/apps/website/backend/src/feed/feed.ts @@ -113,15 +113,19 @@ type LinkRow = { installId: string; product: string; url: string; showEvents: bo export type SyncResult = { installId: string; ok: boolean; imported?: number; deleted?: number; rejected?: number; error?: string }; -/** Fetches one sibling's feed into read-only copies. */ -export async function syncLink(ctx: Ctx, link: LinkRow): Promise { +/** + * Fetches one sibling's feed into read-only copies. `full` asks for the whole list and drops copies + * no longer in it: a sibling that loses events without listing them in `deleted` (a reseed, a + * restore) would otherwise leave stale copies beside the new ones for good. + */ +export async function syncLink(ctx: Ctx, link: LinkRow, { full = false }: { full?: boolean } = {}): Promise { if (link.product === 'accounts') return { installId: link.installId, ok: true, imported: 0 }; if (!link.showEvents) { const gone = (await ctx.db.importedEvent.deleteMany({ where: { linkId: link.installId } })).count; return { installId: link.installId, ok: true, imported: 0, deleted: gone }; } const now = ctx.now(); - const since = link.lastGoodAt ? new Date(link.lastGoodAt.getTime() - OVERLAP_MS) : null; + const since = !full && link.lastGoodAt ? new Date(link.lastGoodAt.getTime() - OVERLAP_MS) : null; try { const url = await siblingUrl(ctx, link.url, FEED_PATHS.events); if (since) url.searchParams.set('updatedSince', since.toISOString()); @@ -153,11 +157,11 @@ export async function syncLink(ctx: Ctx, link: LinkRow): Promise { } } -/** Every linked sibling, one after another; one failing never stops the rest. */ +/** Every linked sibling's whole list, one after another; one failing never stops the rest. */ export async function syncAll(ctx: Ctx) { const links = await ctx.db.productLink.findMany({ where: { product: { not: 'accounts' } } }); let failed = 0; - for (const link of links) if (!(await syncLink(ctx, link)).ok) failed++; + for (const link of links) if (!(await syncLink(ctx, link, { full: true })).ok) failed++; return { links: links.length, failed }; } diff --git a/apps/website/backend/tests/feed.test.ts b/apps/website/backend/tests/feed.test.ts index ff60b80..c971266 100644 --- a/apps/website/backend/tests/feed.test.ts +++ b/apps/website/backend/tests/feed.test.ts @@ -135,6 +135,19 @@ describe('showing events from Cross Events (Show events from)', () => { assert.equal(await db.importedEvent.count(), 0); }); + it('a full fetch (the 15-minute poll) drops copies of events Events lost without saying (a reseed)', async () => { + const { ctx, events, link, db } = await site(); + events.state.feed = { schema: EVENT_FEED_SCHEMA, generatedAt: new Date().toISOString(), deleted: [], events: [ev('6c7d8e9f-0a1b-4c2d-8e3f-4a5b6c7d8e9f', 'Family Fun Day', 10)] }; + await syncLink(ctx, await link()); + // Reseeded: the same event under a new id, and no word about the old one. + events.state.feed = { schema: EVENT_FEED_SCHEMA, generatedAt: new Date().toISOString(), deleted: [], events: [ev('9f0a1b2c-3d4e-4f5a-8b6c-7d8e9f0a1b2c', 'Family Fun Day', 10)] }; + await syncLink(ctx, await link()); + assert.equal(await db.importedEvent.count(), 2, 'an incremental fetch can\'t know'); + await syncLink(ctx, await link(), { full: true }); + assert.doesNotMatch(events.state.asked.at(-1)!, /updatedSince=/); + assert.deepEqual((await db.importedEvent.findMany()).map((e) => e.originId), ['9f0a1b2c-3d4e-4f5a-8b6c-7d8e9f0a1b2c']); + }); + it('switching Show events off removes its events; a signed event.changed fetches at once', async () => { const { ctx, events, link, db, go, app } = await site(); events.state.feed = { schema: EVENT_FEED_SCHEMA, generatedAt: new Date().toISOString(), deleted: [], events: [ev('6c7d8e9f-0a1b-4c2d-8e3f-4a5b6c7d8e9f', 'Youth camp', 10)] }; diff --git a/apps/website/backend/tests/site.test.ts b/apps/website/backend/tests/site.test.ts index 2956ebe..e5f233d 100644 --- a/apps/website/backend/tests/site.test.ts +++ b/apps/website/backend/tests/site.test.ts @@ -188,6 +188,18 @@ describe('the public site\'s content', () => { assert.equal((await siteContent(h.ctx)).church?.name, 'Acacia Hill Church', 'the profile saved by the first demo stays'); }); + it('1.6.1: loading a demo again lists the old events as removed in the feed, so Cross Events drops its copies', async () => { + const h = await harness({ linked: false }); + const dir = tmp(); + await loadDemo(h.ctx, 'heritage', { uploadDir: dir }); + const old = (await h.db.simpleEvent.findMany()).map((e) => e.id).sort(); + assert.ok(old.length > 0); + await loadDemo(h.ctx, 'community-town', { uploadDir: dir }); + assert.deepEqual((await h.db.feedRemoval.findMany()).map((r) => r.eventId).sort(), old); + const now = (await h.db.simpleEvent.findMany()).map((e) => e.id); + assert.ok(now.length > 0 && now.every((id) => !old.includes(id))); + }); + it('1.3.0: a profile on a site with no church profile at all saves the demo one, so the site has a name', async () => { const h = await harness({ linked: false }); await loadDemo(h.ctx, 'clean-campus', { uploadDir: tmp() }); diff --git a/apps/website/frontend/package.json b/apps/website/frontend/package.json index 6fb66ab..1c2a705 100644 --- a/apps/website/frontend/package.json +++ b/apps/website/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/website-frontend", - "version": "1.6.0", + "version": "1.6.1", "private": true, "description": "Church Website: the church's public site in its template, and the admin", "scripts": { diff --git a/apps/website/frontend/src/site/Header.tsx b/apps/website/frontend/src/site/Header.tsx index b646788..7f864d8 100644 --- a/apps/website/frontend/src/site/Header.tsx +++ b/apps/website/frontend/src/site/Header.tsx @@ -1,20 +1,23 @@ /** * Each template's header (WEBSITE-1.0-PLAN §3, "Headers"), with its options from the Header style * setting. Every header collapses to a Menu button on phones (a
, so it works without - * JavaScript). Links to the church's other sites (Events, App) sit next to the pages (§9). + * JavaScript). Links to the church's other sites sit next to the pages (§9), as "Events site" with an + * external-link icon (1.6.1), so they aren't mistaken for this site's own Events page. */ import Link from "next/link"; +import { ExternalLink } from "lucide-react"; import { productLinks } from "@crosscode/ui"; import { ScrollSolid } from "./ScrollSolid"; import { cx } from "./parts"; import type { Published } from "./types"; -type Item = { label: string; href: string; current: boolean }; +/** `external`: one of the church's other sites (1.6.1), marked so it isn't mistaken for a page here. */ +type Item = { label: string; href: string; current: boolean; external?: boolean }; function items(site: Published, path: string): { nav: Item[]; visit: Item | null } { const pages = site.snapshot.pages; const nav: Item[] = pages.filter((p) => p.inNav).map((p) => ({ label: p.navLabel, href: p.path, current: p.path === path })); - for (const l of site.church ? productLinks(site.church.links, "website") : []) nav.push({ label: l.label, href: l.href, current: false }); + for (const l of site.church ? productLinks(site.church.links, "website") : []) nav.push({ label: `${l.label} site`, href: l.href, current: false, external: true }); const v = pages.find((p) => p.kind === "visit"); return { nav, visit: v ? { label: v.navLabel, href: v.path, current: v.path === path } : null }; } @@ -36,7 +39,10 @@ function Links({ nav, className, linkClass }: { nav: Item[]; className?: string; diff --git a/docs/EVENTS-2.4-PLAN.md b/docs/EVENTS-2.4-PLAN.md index 51f66d8..859b878 100644 --- a/docs/EVENTS-2.4-PLAN.md +++ b/docs/EVENTS-2.4-PLAN.md @@ -237,6 +237,11 @@ from"). When on: secret). It fetches `?updatedSince=`, 15 s timeout, parses with `parseEventFeed` (rejected events are logged, never block the rest), and upserts into `ImportedEvent`. One failing link never holds up another (separate jobs). + **Changed in Events 3.7.2 / Website 1.6.1:** the 15-minute poll and "Sync now" fetch the whole + list (no `updatedSince`) and drop copies that aren't in it, so events a sibling lost without + listing them in `deleted` (a reseed, a restore) can't stay forever. Only the fetch after an + `event.changed` asks for what changed. Demo reseeds (`set-demo.js`, the Website's `loadDemo`) + list the old events in `deleted` and send `event.changed`, so siblings are right at once. - **The last good copy stays.** A failed sync only sets `lastSyncError`; admins see "Last synced 2 hours ago" on Linked products and on the dashboard's event list. - **Read-only**, keyed by `origin.product` + `id` (`eventKey`), and **never re-published**: the diff --git a/docs/VERSIONS.md b/docs/VERSIONS.md index d3321fb..7e323a1 100644 --- a/docs/VERSIONS.md +++ b/docs/VERSIONS.md @@ -10,8 +10,8 @@ separately below; the two often differ. | What | Repo | Latest | Tag | Released | |------|------|--------|-----|----------| -| Cross Events | `crosscode-platform` (`apps/events`) | **3.7.1** | `events@3.7.1` | 2026-11-26 | -| Church Website | `crosscode-platform` (`apps/website`) | **1.6.0** | `website@1.6.0` | 2026-11-27 | +| Cross Events | `crosscode-platform` (`apps/events`) | **3.7.2** | `events@3.7.2` | 2026-11-27 | +| Church Website | `crosscode-platform` (`apps/website`) | **1.6.1** | `website@1.6.1` | 2026-11-27 | | Accounts | `crosscode-platform` (`apps/accounts`) | **1.8.0** | `accounts@1.8.0` | 2026-11-26 | | Server agent | `crosscode-platform` (`apps/agent`) | **1.6.0** | `agent@1.6.0` | 2026-11-27 | | Contracts | `crosscode-platform` (`packages/contracts`) | **1.19.0** | `contracts@1.19.0` | 2026-11-27 | @@ -30,7 +30,7 @@ on each run, so merging to `main` and pushing releases it. Its changes are liste | `@crosscode/auth-client` | `packages/auth-client` | 1.1.0 (released with Events 3.0.0 and Accounts 1.1.0) | | `@crosscode/seo` | `packages/seo` | 1.0.0 (released with Events 2.4.0) | | `@crosscode/ui` | `packages/ui` | 0.3.0 (fonts, `ChurchFooter`; 0.2.0 with Accounts 1.7.0, 0.3.0 with Events 3.7.0) | -| Website | `apps/website` | 1.6.0 (1.0.0–1.1.0 released 2026-11-26, 1.2.0–1.6.0 on 2026-11-27; installed for the demo church cross-demo2 (1.6.0) only, Hope Family Church next) | +| Website | `apps/website` | 1.6.1 (1.0.0–1.1.0 released 2026-11-26, 1.2.0–1.6.1 on 2026-11-27; installed for the demo church cross-demo2 (1.6.0) only, Hope Family Church next) | | App | `apps/app` | 0.0.0 (not started, phase 6) | These shared packages ship inside the apps that use them, from the same checkout, so they don't @@ -38,6 +38,12 @@ need their own tags until something outside this repo depends on them. ## What each latest release was for +- **Cross Events 3.7.2 + Church Website 1.6.1 (2026-11-27):** events from the other product no + longer show twice after a reseed: the 15-minute feed poll and "Sync now" fetch the whole list and + drop copies that are gone, and both demo loaders list the old events as removed and tell the + other product at once (Events' `set-demo.js` also fetches the Website's events back in). The + Website's header says "Events site" with an external-link icon instead of a second "Events". + **Not deployed yet.** - **crosscode.co.za 1.9.1 (2026-11-27):** the web address examples (both product pages and the Church Website brochure) say yourchurch instead of a real church's name (hopefamily). **Not deployed yet.** diff --git a/package-lock.json b/package-lock.json index 656254d..8a0c723 100644 --- a/package-lock.json +++ b/package-lock.json @@ -133,7 +133,7 @@ }, "apps/events/backend": { "name": "@crosscode/events-backend", - "version": "3.7.1", + "version": "3.7.2", "hasInstallScript": true, "dependencies": { "@cj-tech-master/excelts": "^10.2.0", @@ -183,7 +183,7 @@ }, "apps/events/frontend": { "name": "@crosscode/events-frontend", - "version": "3.7.1", + "version": "3.7.2", "dependencies": { "@crosscode/contracts": "*", "@crosscode/seo": "*", @@ -360,7 +360,7 @@ }, "apps/website/backend": { "name": "@crosscode/website-backend", - "version": "1.6.0", + "version": "1.6.1", "hasInstallScript": true, "dependencies": { "@crosscode/auth-client": "*", @@ -389,7 +389,7 @@ }, "apps/website/frontend": { "name": "@crosscode/website-frontend", - "version": "1.6.0", + "version": "1.6.1", "dependencies": { "@crosscode/contracts": "*", "@crosscode/seo": "*",