Skip to content

Commit 54c70ad

Browse files
committed
backfill siteUrl
1 parent f773249 commit 54c70ad

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

frontend/src/lib/services/feedFetcher.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,25 @@ export async function fetchAllFeeds(
203203
continue;
204204
}
205205

206-
// Update subscription title/siteUrl from feed metadata (initial pass only)
207-
if (countStatus && feedResult.title) {
206+
// Update subscription title/siteUrl from feed metadata (initial pass only).
207+
// Title and siteUrl are backfilled independently: a sub added before
208+
// siteUrl tracking existed already has its proper title, so gating the
209+
// siteUrl write on a title change would leave it siteUrl-less forever —
210+
// which hides it from cross-type duplicate detection (findCrossTypeDuplicates).
211+
if (countStatus) {
208212
const sub = liveDb.getSubscriptionById(req.subscriptionId);
209-
if (sub && shouldUpdateTitle(sub.title, sub.feedUrl, feedResult.title)) {
210-
await liveDb.updateSubscription(req.subscriptionId, {
211-
title: feedResult.title,
212-
siteUrl: feedResult.siteUrl ?? sub.siteUrl,
213-
localUpdatedAt: Date.now(),
214-
});
213+
if (sub) {
214+
const updates: { title?: string; siteUrl?: string; localUpdatedAt?: number } = {};
215+
if (feedResult.title && shouldUpdateTitle(sub.title, sub.feedUrl, feedResult.title)) {
216+
updates.title = feedResult.title;
217+
}
218+
if (feedResult.siteUrl && feedResult.siteUrl !== sub.siteUrl) {
219+
updates.siteUrl = feedResult.siteUrl;
220+
}
221+
if (updates.title !== undefined || updates.siteUrl !== undefined) {
222+
updates.localUpdatedAt = Date.now();
223+
await liveDb.updateSubscription(req.subscriptionId, updates);
224+
}
215225
}
216226
}
217227

0 commit comments

Comments
 (0)