Skip to content

Commit 6093a43

Browse files
committed
fix(sidebar): stabilize feed order and reduce jitter
- Sort feeds alphabetically in Sidebar to prevent random reordering. - Increase update debounce to 1s (3s during sync) to smooth out jumping numbers. - fix(bookmarks): Use robust in-memory sort for 'Saved' view to fix missing articles issue caused by compound index failure.
1 parent 274a26e commit 6093a43

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

web/src/components/Sidebar.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export function Sidebar({ className }: SidebarProps) {
1919
const pathname = usePathname();
2020
const { isSyncing } = useUIStore();
2121
const folders = useLiveQuery(() => db.folders.orderBy('position').toArray()) || [];
22-
const feeds = useLiveQuery(() => db.feeds.toArray()) || [];
22+
const feeds = useLiveQuery(async () => {
23+
const all = await db.feeds.toArray();
24+
return all.sort((a, b) => (a.title || '').localeCompare(b.title || ''));
25+
}) || [];
2326
const [searchQuery, setSearchQuery] = useState('');
2427

2528
// Sidebar counts - Optimized with Indexes
@@ -76,7 +79,7 @@ export function Sidebar({ className }: SidebarProps) {
7679

7780
const handler = setTimeout(() => {
7881
setCounts(liveCounts);
79-
}, isSyncing ? 2000 : 500);
82+
}, isSyncing ? 3000 : 1000); // Increased debounce to prevent flickering
8083

8184
return () => clearTimeout(handler);
8285
}, [liveCounts, isSyncing]);
@@ -115,7 +118,7 @@ export function Sidebar({ className }: SidebarProps) {
115118

116119
const handler = setTimeout(() => {
117120
setMediaCounts(liveMediaCounts);
118-
}, isSyncing ? 2000 : 500);
121+
}, isSyncing ? 3000 : 1000);
119122

120123
return () => clearTimeout(handler);
121124
}, [liveMediaCounts, isSyncing]);

web/src/hooks/useArticles.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ export function useArticles(
2828
const lastWeek = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
2929
collection = db.articles.where('publishedAt').above(lastWeek);
3030
} else if (view === 'saved') {
31-
collection = db.articles
32-
.where('[isBookmarked+publishedAt]')
33-
.between([1, Dexie.minKey], [1, Dexie.maxKey]);
31+
// Use simple index which is proven to work in Sidebar
32+
const allSaved = await db.articles.where('isBookmarked').equals(1).toArray();
33+
// Sort in memory (newest first)
34+
allSaved.sort((a, b) => {
35+
const dateA = a.publishedAt ? new Date(a.publishedAt).getTime() : 0;
36+
const dateB = b.publishedAt ? new Date(b.publishedAt).getTime() : 0;
37+
return dateB - dateA;
38+
});
39+
// Apply limit and map
40+
return allSaved.slice(0, limit).map(a => ({
41+
...a,
42+
contentHTML: undefined,
43+
readerHTML: undefined,
44+
}));
3445
} else if (view === 'history') {
3546
collection = db.articles.where('isRead').equals(1);
3647
} else if (view === 'youtube') {

0 commit comments

Comments
 (0)