-
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 2 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||
| using Microsoft.AspNetCore.Http; | ||||||
| using Microsoft.AspNetCore.Mvc; | ||||||
| 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 +22,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.
[nitpick] Use object initializer syntax for better readability: var queryParamsDictionary = new Dictionary<string, string>(); or Dictionary<string, string> queryParamsDictionary = new(); (if using C# 9+).
| Dictionary<string, string> queryParamsDictionary = new Dictionary<string, string>(); | |
| var queryParamsDictionary = new Dictionary<string, string>(); |
Outdated
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.
The URI building logic concatenates query parameters manually. Consider using UriBuilder or QueryHelpers.AddQueryString for more maintainable and robust query string construction.
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.
[nitpick] Use string interpolation instead of string.Format for better readability: $\"{uri}&{string.Join(\"&\", queryParamsDictionary.Select(kvp => $\"{kvp.Key}={kvp.Value}\"))}\"
| : string.Format("{0}&{1}", uri, string.Join("&", queryParamsDictionary.Select(kvp => $"{kvp.Key}={kvp.Value}"))); | |
| : $"{uri}&{string.Join("&", queryParamsDictionary.Select(kvp => $"{kvp.Key}={kvp.Value}"))}"; |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,9 @@ export default class ActiveCampaignFormsModalElement | |||||||
| @state() | ||||||||
| _totalPages = 1; | ||||||||
|
|
||||||||
| @state() | ||||||||
| _searchQuery = ""; | ||||||||
|
|
||||||||
| constructor() { | ||||||||
| super(); | ||||||||
|
|
||||||||
|
|
@@ -58,10 +61,10 @@ export default class ActiveCampaignFormsModalElement | |||||||
| await this.#loadForms(); | ||||||||
| } | ||||||||
|
|
||||||||
| async #loadForms(page?: number) { | ||||||||
| async #loadForms(page?: number, searchQuery?: string) { | ||||||||
| this._loading = true; | ||||||||
|
|
||||||||
| const { data } = await this.#activecampaignFormsContext.getForms(page); | ||||||||
| const { data } = await this.#activecampaignFormsContext.getForms(page, searchQuery); | ||||||||
| if (!data) { | ||||||||
| this._loading = false; | ||||||||
| return; | ||||||||
|
|
@@ -75,21 +78,18 @@ export default class ActiveCampaignFormsModalElement | |||||||
| this._loading = false; | ||||||||
| } | ||||||||
|
|
||||||||
| #handleFilterInput(event: UUIInputEvent) { | ||||||||
| async #handleFilterInput(event: UUIInputEvent) { | ||||||||
|
||||||||
| 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 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.
The filter input handler triggers a server call on every keystroke without debouncing, which could result in excessive API requests. Consider implementing debouncing to reduce server load and improve performance.
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.