Skip to content
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

fix/modal search clear #191

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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
2 changes: 1 addition & 1 deletion src/home/home.ts
Original file line number Diff line number Diff line change
@@ -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

7 changes: 4 additions & 3 deletions src/home/sorting/sorting-manager.ts
Original file line number Diff line number Diff line change
@@ -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,
Loading