diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/ChapterVoteComponent.tsx | 64 | ||||
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 2 | ||||
-rw-r--r-- | src/components/options/KeybindComponent.tsx | 3 | ||||
-rw-r--r-- | src/components/options/KeybindDialogComponent.tsx | 3 |
4 files changed, 37 insertions, 35 deletions
diff --git a/src/components/ChapterVoteComponent.tsx b/src/components/ChapterVoteComponent.tsx index 37591f0c..73f14d06 100644 --- a/src/components/ChapterVoteComponent.tsx +++ b/src/components/ChapterVoteComponent.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import Config from "../config"; -import { Category, SegmentUUID, SponsorTime } from "../types"; +import { ActionType, Category, SegmentUUID, SponsorTime } from "../types"; import ThumbsUpSvg from "../svg-icons/thumbs_up_svg"; import ThumbsDownSvg from "../svg-icons/thumbs_down_svg"; @@ -65,35 +65,39 @@ class ChapterVoteComponent extends React.Component<ChapterVoteProps, ChapterVote this.tooltip.close(); this.tooltip = null; } else { - const referenceNode = chapterNode?.parentElement?.parentElement; - if (referenceNode) { - const outerBounding = referenceNode.getBoundingClientRect(); - const buttonBounding = (e.target as HTMLElement)?.parentElement?.getBoundingClientRect(); - - this.tooltip = new Tooltip({ - referenceNode: chapterNode?.parentElement?.parentElement, - prependElement: chapterNode?.parentElement, - showLogo: false, - showGotIt: false, - bottomOffset: `${outerBounding.height + 25}px`, - leftOffset: `${buttonBounding.x - outerBounding.x}px`, - extraClass: "centeredSBTriangle", - buttons: [ - { - name: chrome.i18n.getMessage("incorrectVote"), - listener: (event) => this.vote(event, 0, e.target as HTMLElement).then(() => { - this.tooltip?.close(); - this.tooltip = null; - }) - }, { - name: chrome.i18n.getMessage("harmfulVote"), - listener: (event) => this.vote(event, 30, e.target as HTMLElement).then(() => { - this.tooltip?.close(); - this.tooltip = null; - }) - } - ] - }); + if (this.state.segment?.actionType === ActionType.Chapter) { + const referenceNode = chapterNode?.parentElement?.parentElement; + if (referenceNode) { + const outerBounding = referenceNode.getBoundingClientRect(); + const buttonBounding = (e.target as HTMLElement)?.parentElement?.getBoundingClientRect(); + + this.tooltip = new Tooltip({ + referenceNode: chapterNode?.parentElement?.parentElement, + prependElement: chapterNode?.parentElement, + showLogo: false, + showGotIt: false, + bottomOffset: `${outerBounding.height + 25}px`, + leftOffset: `${buttonBounding.x - outerBounding.x}px`, + extraClass: "centeredSBTriangle", + buttons: [ + { + name: chrome.i18n.getMessage("incorrectVote"), + listener: (event) => this.vote(event, 0, e.target as HTMLElement).then(() => { + this.tooltip?.close(); + this.tooltip = null; + }) + }, { + name: chrome.i18n.getMessage("harmfulVote"), + listener: (event) => this.vote(event, 30, e.target as HTMLElement).then(() => { + this.tooltip?.close(); + this.tooltip = null; + }) + } + ] + }); + } + } else { + this.vote(e, 0, e.target as HTMLElement) } } }}> diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index b84c2b2d..9d7f450f 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -7,13 +7,13 @@ import NoticeTextSelectionComponent from "./NoticeTextSectionComponent"; import Utils from "../utils"; const utils = new Utils(); import { getSkippingText } from "../utils/categoryUtils"; -import { keybindToString } from "../utils/configUtils"; import ThumbsUpSvg from "../svg-icons/thumbs_up_svg"; import ThumbsDownSvg from "../svg-icons/thumbs_down_svg"; import PencilSvg from "../svg-icons/pencil_svg"; import { downvoteButtonColor, SkipNoticeAction } from "../utils/noticeUtils"; import { generateUserID } from "@ajayyy/maze-utils/lib/setup"; +import { keybindToString } from "@ajayyy/maze-utils/lib/config"; enum SkipButtonState { Undo, // Unskip diff --git a/src/components/options/KeybindComponent.tsx b/src/components/options/KeybindComponent.tsx index 4d49c7f4..180d57f2 100644 --- a/src/components/options/KeybindComponent.tsx +++ b/src/components/options/KeybindComponent.tsx @@ -1,9 +1,8 @@ import * as React from "react"; import { createRoot, Root } from 'react-dom/client'; import Config from "../../config"; -import { Keybind } from "../../types"; import KeybindDialogComponent from "./KeybindDialogComponent"; -import { keybindEquals, keybindToString, formatKey } from "../../utils/configUtils"; +import { formatKey, Keybind, keybindEquals, keybindToString } from "@ajayyy/maze-utils/lib/config"; export interface KeybindProps { option: string; diff --git a/src/components/options/KeybindDialogComponent.tsx b/src/components/options/KeybindDialogComponent.tsx index 7226dff2..2c5405f3 100644 --- a/src/components/options/KeybindDialogComponent.tsx +++ b/src/components/options/KeybindDialogComponent.tsx @@ -1,8 +1,7 @@ import * as React from "react"; import { ChangeEvent } from "react"; import Config from "../../config"; -import { Keybind } from "../../types"; -import { keybindEquals, formatKey } from "../../utils/configUtils"; +import { Keybind, formatKey, keybindEquals } from "@ajayyy/maze-utils/lib/config"; export interface KeybindDialogProps { option: string; |