Skip to content

Commit

Permalink
feat: add bot toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
zugdev committed Jan 6, 2025
1 parent a83f772 commit 3e94fb3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReturnType<typeof fetchAllNotifications>> | undefined;

Expand Down
23 changes: 22 additions & 1 deletion src/home/sorting/sorting-manager.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3e94fb3

Please sign in to comment.