fix: session count label distinguishes visible vs total
Show "X visible (Y total)" when the history list is filtered or limited, and "X sessions total" only when every session is actually displayed. Made-with: Cursor
This commit is contained in:
@@ -67,7 +67,10 @@ router.get('/', (req, res) => {
|
|||||||
return { ...session, has_notes, notes_preview };
|
return { ...session, has_notes, notes_preview };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const absoluteTotal = db.prepare('SELECT COUNT(*) as total FROM sessions').get();
|
||||||
|
|
||||||
res.set('X-Total-Count', String(countRow.total));
|
res.set('X-Total-Count', String(countRow.total));
|
||||||
|
res.set('X-Absolute-Total', String(absoluteTotal.total));
|
||||||
res.json(result);
|
res.json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ function History() {
|
|||||||
const [sessions, setSessions] = useState([]);
|
const [sessions, setSessions] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [totalCount, setTotalCount] = useState(0);
|
const [totalCount, setTotalCount] = useState(0);
|
||||||
|
const [absoluteTotal, setAbsoluteTotal] = useState(0);
|
||||||
const [closingSession, setClosingSession] = useState(null);
|
const [closingSession, setClosingSession] = useState(null);
|
||||||
|
|
||||||
const [filter, setFilter] = useState(() => localStorage.getItem(prefixKey(adminName, 'history-filter')) || 'default');
|
const [filter, setFilter] = useState(() => localStorage.getItem(prefixKey(adminName, 'history-filter')) || 'default');
|
||||||
@@ -33,6 +34,7 @@ function History() {
|
|||||||
});
|
});
|
||||||
setSessions(response.data);
|
setSessions(response.data);
|
||||||
setTotalCount(parseInt(response.headers['x-total-count'] || '0', 10));
|
setTotalCount(parseInt(response.headers['x-total-count'] || '0', 10));
|
||||||
|
setAbsoluteTotal(parseInt(response.headers['x-absolute-total'] || '0', 10));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load sessions', err);
|
console.error('Failed to load sessions', err);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -179,7 +181,10 @@ function History() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span className="text-xs text-gray-400 dark:text-gray-500">
|
<span className="text-xs text-gray-400 dark:text-gray-500">
|
||||||
{totalCount} session{totalCount !== 1 ? 's' : ''} total
|
{sessions.length === absoluteTotal
|
||||||
|
? `${absoluteTotal} session${absoluteTotal !== 1 ? 's' : ''} total`
|
||||||
|
: `${sessions.length} visible (${absoluteTotal} total)`
|
||||||
|
}
|
||||||
</span>
|
</span>
|
||||||
{isAuthenticated && (
|
{isAuthenticated && (
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user