From 2005b7d874bb80c6ace59fe8a658ee7672b62780 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Fri, 16 Oct 2026 16:09:59 -0400 Subject: [PATCH] Keep the stored name and URL of connected sites gone from WordPress.com --- packages/common/lib/sync/tests/transform-sites.test.ts | 9 +++++++-- packages/common/lib/sync/transform-sites.ts | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/common/lib/sync/tests/transform-sites.test.ts b/packages/common/lib/sync/tests/transform-sites.test.ts index 185e609696..0ba5082397 100644 --- a/packages/common/lib/sync/tests/transform-sites.test.ts +++ b/packages/common/lib/sync/tests/transform-sites.test.ts @@ -83,7 +83,7 @@ describe( 'transformSitesResponse', () => { } ); describe( 'withWpcomDetails', () => { - it( 'takes details from the site list, keeps the stored sync times, and flags missing sites', () => { + it( 'takes details from the site list, keeps the stored sync times, and keeps the stored name and URL of sites gone from WordPress.com', () => { const atomic = { ...simpleBusinessSite(), ID: 3, is_wpcom_atomic: true, jetpack: true }; const [ business, free ] = transformSitesResponse( [ atomic, freeSite() ] ); const stored = ( id: number ) => ( { @@ -107,6 +107,11 @@ describe( 'withWpcomDetails', () => { lastPushTimestamp: '2026-10-01T09:00:00.000Z', } ); expect( downgraded.syncSupport ).toBe( 'needs-upgrade' ); - expect( gone ).toMatchObject( { id: 99, name: '', syncSupport: 'deleted' } ); + expect( gone ).toMatchObject( { + id: 99, + name: 'Old name', + url: business.url, + syncSupport: 'deleted', + } ); } ); } ); diff --git a/packages/common/lib/sync/transform-sites.ts b/packages/common/lib/sync/transform-sites.ts index c4cc1b0181..620a56792f 100644 --- a/packages/common/lib/sync/transform-sites.ts +++ b/packages/common/lib/sync/transform-sites.ts @@ -76,7 +76,8 @@ export function transformSitesResponse( * access to it. */ export function withWpcomDetails( connections: SyncSite[], wpcomSites: SyncSite[] ): SyncSite[] { - return connections.map( ( { id, localSiteId, lastPullTimestamp, lastPushTimestamp } ) => { + return connections.map( ( connection ) => { + const { id, localSiteId, lastPullTimestamp, lastPushTimestamp } = connection; const site = wpcomSites.find( ( candidate ) => candidate.id === id ); const syncSupport = ! site ? 'deleted' @@ -84,7 +85,8 @@ export function withWpcomDetails( connections: SyncSite[], wpcomSites: SyncSite[ ? 'already-connected' : site.syncSupport; return { - ...( site ?? { id, name: '', url: '', isStaging: false, isPressable: false } ), + // A site gone from WordPress.com keeps the name and URL it was connected under. + ...( site ?? connection ), localSiteId, syncSupport, lastPullTimestamp,