Skip to content

Commit

Permalink
fix: fight with linter, win
Browse files Browse the repository at this point in the history
  • Loading branch information
d0kur0 committed Oct 21, 2023
1 parent dc1407b commit b9a0f84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
18 changes: 8 additions & 10 deletions src/components/FileViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Button, ButtonGroup, IconButton, Spinner } from "@hope-ui/solid";
import { useNavigate } from "@solidjs/router";
import { IoClose } from "solid-icons/io";
import { createEffect, createMemo, createSignal } from "solid-js";
import { onMount, createMemo, createSignal, onCleanup } from "solid-js";
import { ExtendedFile, isFileImage } from "../utils/grabbing";

type FileViewerProps = {
Expand Down Expand Up @@ -29,16 +29,14 @@ export function FileViewer(props: FileViewerProps) {
const [isLoading, setIsLoading] = createSignal(true);
const [isLoadingFailed, setIsLoadingFailed] = createSignal(false);

createEffect(() => {
const listener = (event: KeyboardEvent) => {
event.key === "Escape" && props.onClose?.();
event.key === "ArrowLeft" && props.onPrev?.();
event.key === "ArrowRight" && props.onNext?.();
};
const listener = (event: KeyboardEvent) => {
event.key === "Escape" && props.onClose?.();
event.key === "ArrowLeft" && props.onPrev?.();
event.key === "ArrowRight" && props.onNext?.();
};

window.addEventListener("keydown", listener);
return () => window.removeEventListener("keydown", listener);
});
onMount(() => window.addEventListener("keydown", listener));
onCleanup(() => window.removeEventListener("keydown", listener));

const navigateToThread = () => {
navigate(`/thread/${props.file.rootThread.board}/${props.file.rootThread.id}`);
Expand Down
17 changes: 13 additions & 4 deletions src/pages/PageListFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ export function PageListFiles() {
};

const handleAddToExcludeThreads = () => {
if (!thread()) return;
const threadInfo = thread();
if (!threadInfo) return;

$excludeRulesMutations.addThread({ id: thread()?.id!, board: thread()?.board! });
$excludeRulesMutations.addThread({ id: threadInfo.id, board: threadInfo.board });

notificationService.show({
title: "Добавлено в исключения",
Expand All @@ -65,9 +66,17 @@ export function PageListFiles() {
};

const handleAddToExcludeWords = () => {
if (!thread()?.subject) return;
const threadInfo = thread();

$excludeRulesMutations.addWord(thread()?.subject!);
if (!threadInfo?.subject) {
return notificationService.show({
title: "Ошибка",
status: "danger",
description: "Тред невозможно добавить в бан-ворды, нет сабжа, попробуй скрыть по ID",
});
}

$excludeRulesMutations.addWord(threadInfo.subject);

notificationService.show({
title: "Добавлено в бан ворды",
Expand Down

0 comments on commit b9a0f84

Please sign in to comment.