mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Fold pagination +1 trick into API methods, return typed records
Remove dead _pageSize from BackendAPI and centralise the
"fetch perPage+1, detect hasNextPage, trim" logic into
listDevices and listNotifications. Both methods now accept
page/perPage and return ({items, hasNextPage}) records,
eliminating the duplicated boilerplate at each call site.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f75d1ce313
commit
8be65f3ffa
@@ -115,17 +115,17 @@ class _NotificationsListState extends State<NotificationsList>
|
||||
_error = null;
|
||||
});
|
||||
try {
|
||||
final results = await BackendAPI.instance.listNotifications(
|
||||
final result = await BackendAPI.instance.listNotifications(
|
||||
_filter.isNew,
|
||||
page * _pageSize,
|
||||
limit: _pageSize + 1,
|
||||
page: page,
|
||||
perPage: _pageSize,
|
||||
cancelToken: token,
|
||||
);
|
||||
if (!mounted || token != _fetchToken) return;
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
_hasNextPage = results.length > _pageSize;
|
||||
_items = _hasNextPage ? results.take(_pageSize).toList() : results;
|
||||
_hasNextPage = result.hasNextPage;
|
||||
_items = result.items;
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user