mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-08-18 08:27:14 +02:00
fix saved pagination value is handled by url params
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
@@ -71,7 +71,6 @@ class URLUpdateQueue {
|
||||
export const newTableURLParams = (
|
||||
options = {
|
||||
page: defaultStartPage,
|
||||
perPage: defaultPerPage,
|
||||
sortBy: defaultSortBy,
|
||||
sortOrder: defaultSortOrder,
|
||||
search: '',
|
||||
@@ -88,7 +87,8 @@ export const newTableURLParams = (
|
||||
|
||||
// first add the default values
|
||||
const state = {
|
||||
...defaultOptions
|
||||
...defaultOptions,
|
||||
perPage: storedPerPage // use fresh value from localStorage instead of stale defaultOptions
|
||||
};
|
||||
if (options.page) {
|
||||
state.page = options.page;
|
||||
@@ -120,10 +120,11 @@ export const newTableURLParams = (
|
||||
if (urlParamsPage) {
|
||||
state.page = urlParamsPage;
|
||||
}
|
||||
const urlParamsperPage = parseInt(urlParams.get(param('perPage', state.prefix)));
|
||||
if (urlParamsperPage) {
|
||||
state.perPage = urlParamsperPage;
|
||||
}
|
||||
// don't override perPage from URL - localStorage preference takes priority
|
||||
// const urlParamsperPage = parseInt(urlParams.get(param('perPage', state.prefix)));
|
||||
// if (urlParamsperPage) {
|
||||
// state.perPage = urlParamsperPage;
|
||||
// }
|
||||
const urlParamsSortBy = urlParams.get(param('sortBy', state.prefix));
|
||||
if (urlParamsSortBy) {
|
||||
state.sortBy = urlParamsSortBy;
|
||||
@@ -144,7 +145,7 @@ export const newTableURLParams = (
|
||||
}
|
||||
if (state.perPage < minPerPage || state.perPage > maxPerPage) {
|
||||
console.warn('adjusting pagination: perPage < minPerPage || perPage > maxPerPage');
|
||||
state.perPage = defaultOptions.perPage;
|
||||
state.perPage = storedPerPage;
|
||||
}
|
||||
if (acceptedPerPageValues.includes(state.perPage) === false) {
|
||||
console.warn('adjusting pagination: acceptedPerPageValues.includes(perPage) === false');
|
||||
|
||||
@@ -12,11 +12,8 @@
|
||||
import TableRow from '$lib/components/table/TableRow.svelte';
|
||||
import TableCell from '$lib/components/table/TableCell.svelte';
|
||||
import { formatWeekDays, formatTimeConstraint, timeFormat } from '$lib/utils/date.js';
|
||||
import {
|
||||
defaultPerPage,
|
||||
defaultStartPage,
|
||||
newTableURLParams
|
||||
} from '$lib/service/tableURLParams.js';
|
||||
import { defaultStartPage, newTableURLParams } from '$lib/service/tableURLParams.js';
|
||||
import { getPerPagePreference } from '$lib/store/preferences.js';
|
||||
import Table from '$lib/components/table/Table.svelte';
|
||||
import TableCellEmpty from '$lib/components/table/TableCellEmpty.svelte';
|
||||
import TableCellAction from '$lib/components/table/TableCellAction.svelte';
|
||||
@@ -479,7 +476,7 @@
|
||||
recipientEventsTableParams.unsubscribe();
|
||||
recipientEventsTableParams.search = '';
|
||||
recipientEventsTableParams.page = defaultStartPage;
|
||||
recipientEventsTableParams.perPage = defaultPerPage;
|
||||
recipientEventsTableParams.perPage = getPerPagePreference();
|
||||
|
||||
recipientEvents = [];
|
||||
recipientEventsRecipient = {
|
||||
|
||||
Reference in New Issue
Block a user