Skip to content

Commit

Permalink
Merge pull request #191 from zugdev/fix/modal-search-clear
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Jan 5, 2025
2 parents 97b86d7 + f5dc917 commit a721d41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/home/fetch-github/fetch-and-display-previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ export type Options = {
ordering: "normal" | "reverse";
};

export let isFilteringAvailableIssues = true;
// decide initial value based on URL
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");
}
console.log(newURL.toString());
window.history.replaceState({}, "", newURL.toString());
}

// start at view based on URL
Expand Down
2 changes: 1 addition & 1 deletion src/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void (async function home() {
void authentication();
void readyToolbar();
await taskManager.syncTasks(); // Sync tasks from cache on load
loadIssueFromUrl(); // Load issue preview from URL if present
await loadIssueFromUrl(); // Load issue preview from URL if present
void displayGitHubIssues(); // Display issues from cache
await postLoadUpdateIssues(); // Update cache and issues if cache is outdated

Expand Down
7 changes: 4 additions & 3 deletions src/home/sorting/sorting-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,16 @@ export class SortingManager {
input.type = "button";
input.value = "Unassigned";
input.id = `filter-availability-${this._instanceId}`;
// decide initial value based on URL
if(new URLSearchParams(window.location.search).get("allIssues") === "true"){
input.value = "All Issues";
}

input.addEventListener("click", () => {
swapAvailabilityFilter();
input.value = isFilteringAvailableIssues ? "Unassigned" : "All Issues";

try {
// Clear search when applying the filter
this._resetSearchBar();

const { sortingOption, sortingOrder } = this._detectSortingState();
void displayGitHubIssues({
sorting: sortingOption as Sorting,
Expand Down

0 comments on commit a721d41

Please sign in to comment.