diff --git a/src/home/home.ts b/src/home/home.ts index 8a059fa..10435b9 100644 --- a/src/home/home.ts +++ b/src/home/home.ts @@ -30,6 +30,12 @@ if (!notificationsContainer) { throw new Error("Could not find issues container"); } +// Should show bot +export let showBotNotifications = false; +export const flipShowBotNotifications = () => { + showBotNotifications = !showBotNotifications; +} + // Store notifications let notifications: Awaited> | undefined; diff --git a/src/home/sorting/sorting-manager.ts b/src/home/sorting/sorting-manager.ts index 72dac5a..682c3d5 100644 --- a/src/home/sorting/sorting-manager.ts +++ b/src/home/sorting/sorting-manager.ts @@ -1,5 +1,5 @@ import { displayNotifications } from "../fetch-github/filter-and-display-notifications"; -import { getNotifications } from "../home"; +import { flipShowBotNotifications, getNotifications, showBotNotifications } from "../home"; import { renderErrorInModal } from "../rendering/display-popup-modal"; import { Sorting } from "./generate-sorting-buttons"; @@ -120,6 +120,27 @@ export class SortingManager { const buttons = document.createElement("div"); buttons.className = "labels"; + const input = document.createElement("input"); + input.style.display = "none"; + input.type = "button"; + input.id = `filter-bot-${this._instanceId}`; + const label = document.createElement("label"); + label.htmlFor = `filter-bot-${this._instanceId}`; + label.textContent = showBotNotifications ? "Hide Bot" : "Show Bot"; + + input.addEventListener("click", () => { + flipShowBotNotifications(); + label.textContent = showBotNotifications ? "Hide Bot" : "Show Bot"; + try { + void displayNotifications(); + } catch (error) { + renderErrorInModal(error as Error); + } + }); + + buttons.appendChild(input); + buttons.appendChild(label); + sortingOptions.forEach((option) => { const input = this._createRadioButton(option); const label = this._createLabel(option);