-
Notifications
You must be signed in to change notification settings - Fork 24
Bugfix/v16/activecampaign/pagination filtering #284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
a1a28d3
b8f07f0
3cb8c08
1798828
584d3c1
1b730ce
6187c87
710ea33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||
| using Asp.Versioning; | ||||||
| using Microsoft.AspNetCore.Http; | ||||||
| using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.AspNetCore.WebUtilities; | ||||||
| using Microsoft.Extensions.Options; | ||||||
| using System.Web; | ||||||
| using Umbraco.Cms.Api.Common.Builders; | ||||||
| using Umbraco.Cms.Integrations.Crm.ActiveCampaign.Configuration; | ||||||
| using Umbraco.Cms.Integrations.Crm.ActiveCampaign.Models.Dtos; | ||||||
|
|
@@ -21,15 +23,13 @@ public GetFormsByPageController(IOptions<ActiveCampaignSettings> options, IHttpC | |||||
| [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||||
| [ProducesResponseType(StatusCodes.Status403Forbidden)] | ||||||
| [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
| public async Task<IActionResult> GetForms([FromQuery] int? page = 1) | ||||||
| public async Task<IActionResult> GetForms([FromQuery] int? page = 1, string? searchQuery = "") | ||||||
|
||||||
| public async Task<IActionResult> GetForms([FromQuery] int? page = 1, string? searchQuery = "") | |
| public async Task<IActionResult> GetForms([FromQuery] int? page = 1, [FromQuery] string? searchQuery = "") |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URI construction manually appends '?limit=' without checking if ApiPath already contains query parameters. If ApiPath includes a query string, this will produce malformed URIs. Use QueryHelpers.AddQueryString for the limit parameter as well to handle this correctly.
| var uri = $"{baseAddress}{ApiPath}?limit={Constants.DefaultPageSize}"; | |
| var uri = QueryHelpers.AddQueryString($"{baseAddress}{ApiPath}", "limit", Constants.DefaultPageSize.ToString()); |
Outdated
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The queryParamsDictionary is declared but never populated or used. The query parameters are being added directly to the URI using QueryHelpers.AddQueryString. This unused variable should be removed along with the unnecessary conditional logic at lines 67-69 that references it.
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,11 @@ export default class ActiveCampaignFormsModalElement | |||||||||||
| @state() | ||||||||||||
| _totalPages = 1; | ||||||||||||
|
|
||||||||||||
| @state() | ||||||||||||
| _searchQuery = ""; | ||||||||||||
|
|
||||||||||||
| #filterTimeout?: NodeJS.Timeout; | ||||||||||||
|
|
||||||||||||
| constructor() { | ||||||||||||
| super(); | ||||||||||||
|
|
||||||||||||
|
|
@@ -47,6 +52,10 @@ export default class ActiveCampaignFormsModalElement | |||||||||||
| this.#checkApiAccess(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| disconnectedCallback() { | ||||||||||||
| clearTimeout(this.#filterTimeout); | ||||||||||||
|
||||||||||||
| clearTimeout(this.#filterTimeout); | |
| super.disconnectedCallback(); | |
| if (this.#filterTimeout !== undefined) { | |
| clearTimeout(this.#filterTimeout); | |
| } |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is marked as async but doesn't await the setTimeout callback. This can lead to unhandled promise rejections if the loadForms call fails. Consider removing async from the method signature since the actual async work happens in the timeout callback.
| async #handleFilterInput(event: UUIInputEvent) { | |
| #handleFilterInput(event: UUIInputEvent) { |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When filtering is applied, the page number should be reset to 1 to avoid displaying empty results if the current page exceeds the filtered result set. Consider resetting this._currentPageNumber to 1 before calling #loadForms.
| this._currentPageNumber = 1; |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout is not cleared when the component is destroyed, which could lead to attempted state updates after the element is removed from the DOM. Add cleanup in a disconnectedCallback or similar lifecycle method to clear this.#filterTimeout.
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The 500ms debounce timeout is hardcoded. Consider extracting this to a constant (e.g., SEARCH_DEBOUNCE_MS) to improve maintainability and make it easier to adjust the debounce delay if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
System.Webimport at line 6 is unnecessary sinceQueryHelpers.AddQueryStringfromMicrosoft.AspNetCore.WebUtilitiesis being used for URL encoding. Remove the unusedSystem.Webimport.