From ef784f791c0939698d51bd03fcb6a928250dcea0 Mon Sep 17 00:00:00 2001 From: zugdev Date: Sun, 5 Jan 2025 16:52:42 -0300 Subject: [PATCH 1/2] feat: fix search --- .../fetch-github/fetch-and-display-previews.ts | 10 +++++----- src/home/sorting/sorting-manager.ts | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/home/fetch-github/fetch-and-display-previews.ts b/src/home/fetch-github/fetch-and-display-previews.ts index 442393b..fb4603a 100644 --- a/src/home/fetch-github/fetch-and-display-previews.ts +++ b/src/home/fetch-github/fetch-and-display-previews.ts @@ -14,17 +14,17 @@ export type Options = { }; // decide initial value based on URL -export let isFilteringAvailableIssues = (new URLSearchParams(window.location.search).get("allIssues") === "true") ? false : true; +export let isFilteringAvailableIssues = new URLSearchParams(window.location.search).get("allIssues") === "true" ? false : true; export function swapAvailabilityFilter() { isFilteringAvailableIssues = !isFilteringAvailableIssues; //url part const newURL = new URL(window.location.href); - if(isFilteringAvailableIssues){ - newURL.searchParams.delete("allIssues") - } else { - newURL.searchParams.set("allIssues","true"); + if (isFilteringAvailableIssues) { + newURL.searchParams.delete("allIssues"); + } else { + newURL.searchParams.set("allIssues", "true"); } console.log(newURL.toString()); window.history.replaceState({}, "", newURL.toString()); diff --git a/src/home/sorting/sorting-manager.ts b/src/home/sorting/sorting-manager.ts index 58437cf..654a8bd 100644 --- a/src/home/sorting/sorting-manager.ts +++ b/src/home/sorting/sorting-manager.ts @@ -174,7 +174,7 @@ export class SortingManager { input.value = "Unassigned"; input.id = `filter-availability-${this._instanceId}`; // decide initial value based on URL - if(new URLSearchParams(window.location.search).get("allIssues") === "true"){ + if (new URLSearchParams(window.location.search).get("allIssues") === "true") { input.value = "All Issues"; } @@ -183,11 +183,16 @@ export class SortingManager { input.value = isFilteringAvailableIssues ? "Unassigned" : "All Issues"; try { - const { sortingOption, sortingOrder } = this._detectSortingState(); - void displayGitHubIssues({ - sorting: sortingOption as Sorting, - options: { ordering: sortingOrder }, - }); + const filterTextBox = this._filtersDiv.querySelector('input[type="text"]') as HTMLInputElement; + if(filterTextBox.value){ + void searchDisplayGitHubIssues({searchText: filterTextBox.value}); + }else { + const { sortingOption, sortingOrder } = this._detectSortingState(); + void displayGitHubIssues({ + sorting: sortingOption as Sorting, + options: { ordering: sortingOrder }, + }); + } } catch (error) { renderErrorInModal(error as Error); } From e4e9cbabb38819472dc7c12f557701357363d225 Mon Sep 17 00:00:00 2001 From: zugdev Date: Sun, 5 Jan 2025 16:53:21 -0300 Subject: [PATCH 2/2] feat: lint --- src/home/sorting/sorting-manager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/home/sorting/sorting-manager.ts b/src/home/sorting/sorting-manager.ts index 654a8bd..3d6ff2b 100644 --- a/src/home/sorting/sorting-manager.ts +++ b/src/home/sorting/sorting-manager.ts @@ -184,9 +184,9 @@ export class SortingManager { try { const filterTextBox = this._filtersDiv.querySelector('input[type="text"]') as HTMLInputElement; - if(filterTextBox.value){ - void searchDisplayGitHubIssues({searchText: filterTextBox.value}); - }else { + if (filterTextBox.value) { + void searchDisplayGitHubIssues({ searchText: filterTextBox.value }); + } else { const { sortingOption, sortingOrder } = this._detectSortingState(); void displayGitHubIssues({ sorting: sortingOption as Sorting,