@servicemind.tis/tis-smart-table-viewer 2.4.13 → 2.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -163,7 +163,17 @@ const getFromLocalStorageWithExpiry = (key) => {
163
163
  if (!itemStr) {
164
164
  return null;
165
165
  }
166
- const item = JSON.parse(itemStr);
166
+ // Guard against corrupt / non-JSON values (e.g. written by an older version
167
+ // or other code). Treat an unparseable entry as missing and self-heal by
168
+ // removing it, instead of throwing and breaking the caller (ngOnChanges).
169
+ let item;
170
+ try {
171
+ item = JSON.parse(itemStr);
172
+ }
173
+ catch {
174
+ localStorage.removeItem(key);
175
+ return null;
176
+ }
167
177
  const now = new Date();
168
178
  if (!item.expiry) {
169
179
  localStorage.removeItem(key);
@@ -2491,20 +2501,29 @@ class TisSmartTableViewerComponent {
2491
2501
  this.resetFlag = false;
2492
2502
  }
2493
2503
  onPaginationChanges() {
2494
- if (this.pageIndex != this._paginator.pageIndex) {
2495
- this.pageIndex = this._paginator.pageIndex;
2504
+ // Read both new values up front. Changing the page size on a non-first page
2505
+ // makes mat-paginator recompute pageIndex AND pageSize in a single event;
2506
+ // handling them in two separate getList() calls used to fail because the
2507
+ // first call writes the (still old) pageSize back onto the paginator
2508
+ // (see getList), making the second comparison false and dropping the new
2509
+ // page size. Capture both, apply both, and load once.
2510
+ const newPageIndex = this._paginator.pageIndex;
2511
+ const newPageSize = this._paginator.pageSize;
2512
+ const pageIndexChanged = this.pageIndex != newPageIndex;
2513
+ const pageSizeChanged = this.pageSize != newPageSize;
2514
+ if (pageIndexChanged || pageSizeChanged) {
2515
+ this.pageIndex = newPageIndex;
2516
+ this.pageSize = newPageSize;
2496
2517
  // Clear computed backgrounds before loading new page data
2497
2518
  this.clearRowBackgroundCache();
2498
2519
  this.getList();
2499
- this.pageIndexChange.emit(this.pageIndex);
2500
- }
2501
- if (this.pageSize != this._paginator.pageSize) {
2502
- this.pageSize = this._paginator.pageSize;
2503
- // Clear computed backgrounds before loading new page size data
2504
- this.clearRowBackgroundCache();
2505
- this.getList();
2506
- this.pageSizeChange.emit(this.pageSize);
2507
- setToLocalStorageWithExpiry('user_pagination_page_size', this.pageSize, 1000 * 60 * 60 * 24 * 15);
2520
+ if (pageIndexChanged) {
2521
+ this.pageIndexChange.emit(this.pageIndex);
2522
+ }
2523
+ if (pageSizeChanged) {
2524
+ this.pageSizeChange.emit(this.pageSize);
2525
+ setToLocalStorageWithExpiry('user_pagination_page_size', this.pageSize, 1000 * 60 * 60 * 24 * 15);
2526
+ }
2508
2527
  }
2509
2528
  }
2510
2529
  onSetSelectedTemplate(data) {