fix(api_service): adjust pagination to 1-based index for OpenWebUI compatibility
This commit is contained in:
@@ -283,7 +283,10 @@ class ApiService {
|
|||||||
if (limit == null) {
|
if (limit == null) {
|
||||||
// Fetch all conversations using pagination
|
// Fetch all conversations using pagination
|
||||||
|
|
||||||
int currentPage = 0;
|
// OpenWebUI expects 1-based pagination for the `page` query param.
|
||||||
|
// Using 0 triggers server-side offset calculation like `offset = page*limit - limit`,
|
||||||
|
// which becomes negative for page=0 and causes a DB error.
|
||||||
|
int currentPage = 1;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
final response = await _dio.get(
|
final response = await _dio.get(
|
||||||
@@ -322,7 +325,12 @@ class ApiService {
|
|||||||
// Original single page fetch
|
// Original single page fetch
|
||||||
final regularResponse = await _dio.get(
|
final regularResponse = await _dio.get(
|
||||||
'/api/v1/chats/',
|
'/api/v1/chats/',
|
||||||
queryParameters: {if (limit > 0) 'page': ((skip ?? 0) / limit).floor()},
|
// Convert skip/limit to 1-based page index expected by OpenWebUI.
|
||||||
|
// Example: skip=0 => page=1, skip=limit => page=2, etc.
|
||||||
|
queryParameters: {
|
||||||
|
if (limit > 0)
|
||||||
|
'page': (((skip ?? 0) / limit).floor() + 1).clamp(1, 1 << 30),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (regularResponse.data is! List) {
|
if (regularResponse.data is! List) {
|
||||||
|
|||||||
Reference in New Issue
Block a user