Skip to content

Commit

Permalink
Merge pull request galaxyproject#19409 from jdavcs/dev_pagination_fix
Browse files Browse the repository at this point in the history
Prevent negative offset
  • Loading branch information
martenson authored Jan 16, 2025
2 parents 2411fb8 + 75cf57a commit 4e781cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/components/FilesDialog/FilesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ async function provideItems(ctx: ItemsProviderContext, url?: string): Promise<Se
return [];
}
const limit = ctx.perPage;
const offset = (ctx.currentPage - 1) * ctx.perPage;
const offset = (ctx.currentPage ? ctx.currentPage - 1 : 0) * ctx.perPage;
const query = ctx.filter;
const response = await browseRemoteFiles(url, false, props.requireWritable, limit, offset, query);
const result = response.entries.map(entryToRecord);
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Grid/GridList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async function getGridData() {
return;
}
try {
const offset = props.limit * (currentPage.value - 1);
const offset = props.limit * (currentPage.value ? currentPage.value - 1 : 0);
const [responseData, responseTotal] = await props.gridConfig.getData(
offset,
props.limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async function historiesProvider(ctx: ItemsProviderContext, url?: string): Promi
}
const limit = ctx.perPage;
const offset = (ctx.currentPage - 1) * ctx.perPage;
const offset = (ctx.currentPage ? ctx.currentPage - 1 : 0) * ctx.perPage;
const sortDesc = ctx.sortDesc;
const sortBy: HistorySortByLiteral =
ctx.sortBy === "label" ? "name" : (ctx.sortBy as HistorySortByLiteral) || "update_time";
Expand Down Expand Up @@ -201,7 +201,7 @@ async function datasetsProvider(ctx: ItemsProviderContext, selectedHistory: Hist
try {
const limit = ctx.perPage;
const offset = (ctx.currentPage - 1) * ctx.perPage;
const offset = (ctx.currentPage ? ctx.currentPage - 1 : 0) * ctx.perPage;
const query = ctx.filter || "";
const querySortBy = ctx.sortBy === "time" ? "update_time" : "name";
const sortPrefix = ctx.sortDesc ? "-dsc" : "-asc";
Expand Down

0 comments on commit 4e781cd

Please sign in to comment.