feat: paginate duplicates view — 20 per page with Load more
Server returns page/limit/pages metadata; client fetches 20 groups at a time and appends on "Load more". Shows remaining count in the button. Dismiss and keep-best remove from the local list without a refetch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f7dd3b49b
commit
64cca095ea
3 files changed
+91
-39
No files matched your search
+12
-3
@@ -568,9 +568,17 @@ app.post('/api/dedupe/scan', async (_req, res) => {
|
||||
} catch (e) { res.status(500).json({ error: e.message }); }
|
||||
});
|
||||
|
||||
app.get('/api/duplicates', (_req, res) => {
|
||||
app.get('/api/duplicates', (req, res) => {
|
||||
const PAGE_SIZE = 20;
|
||||
const page = Math.max(1, parseInt(req.query.page ?? '1', 10));
|
||||
const limit = Math.min(100, Math.max(1, parseInt(req.query.limit ?? String(PAGE_SIZE), 10)));
|
||||
|
||||
const rawGroups = getGroups(db);
|
||||
const groups = rawGroups.map(group =>
|
||||
const total = rawGroups.length;
|
||||
const start = (page - 1) * limit;
|
||||
const slice = rawGroups.slice(start, start + limit);
|
||||
|
||||
const groups = slice.map(group =>
|
||||
group.map(p => ({
|
||||
id: p.id,
|
||||
date_taken: p.date_taken,
|
||||
@@ -582,7 +590,8 @@ app.get('/api/duplicates', (_req, res) => {
|
||||
preview_url: posterUrl(p.preview_path),
|
||||
}))
|
||||
);
|
||||
res.json({ groups, total: groups.length });
|
||||
|
||||
res.json({ groups, total, page, limit, pages: Math.ceil(total / limit) });
|
||||
});
|
||||
|
||||
app.post('/api/duplicates/dismiss', (req, res) => {
|
||||
|
||||
Reference in new issue
Block a user