diff --git a/src/home/fetch-github/fetch-and-display-previews.ts b/src/home/fetch-github/fetch-and-display-previews.ts index e6edbc8..442393b 100644 --- a/src/home/fetch-github/fetch-and-display-previews.ts +++ b/src/home/fetch-github/fetch-and-display-previews.ts @@ -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 diff --git a/src/home/home.ts b/src/home/home.ts index 8a7b233..9d0abba 100644 --- a/src/home/home.ts +++ b/src/home/home.ts @@ -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 diff --git a/src/home/sorting/sorting-manager.ts b/src/home/sorting/sorting-manager.ts index cbe7ee0..58437cf 100644 --- a/src/home/sorting/sorting-manager.ts +++ b/src/home/sorting/sorting-manager.ts @@ -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,