Skip to content

Commit

Permalink
fix: 타입 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kangju2000 committed Oct 25, 2024
1 parent 1c704d3 commit b4bda2d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
chrome.runtime.onInstalled.addListener(async () => {
for (const cs of chrome.runtime.getManifest().content_scripts) {
for (const tab of await chrome.tabs.query({ url: cs.matches })) {
for (const cs of chrome.runtime.getManifest().content_scripts ?? []) {
for (const tab of await chrome.tabs.query({ url: cs.matches ?? [] })) {
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: cs.js,
target: { tabId: tab.id ?? 0 },
files: cs.js ?? [],
})
cs.css?.forEach(css => {
chrome.scripting.insertCSS({
target: { tabId: tab.id },
target: { tabId: tab.id ?? 0 },
files: [css],
})
})
Expand Down
13 changes: 11 additions & 2 deletions src/content/components/Trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ import { MainModal } from './MainModal'
import { useShadowRoot } from '@/hooks/useShadowRoot'
import { useShortcutStore } from '@/storage/useShortcutStore'
import { useStorageStore } from '@/storage/useStorageStore'
import type { StorageData } from '@/types'

const isActiveElementEditable = (element: Element | null): boolean => {
return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement
}

const TriggerButton = ({ isOpen, onClick, settings }) => (
const TriggerButton = ({
isOpen,
onClick,
settings,
}: {
isOpen: boolean
onClick: () => void
settings: StorageData['settings']
}) => (
<div
onClick={onClick}
className="d-mask d-mask-squircle fixed bottom-25px right-25px h-56px w-56px cursor-pointer bg-cover bg-center bg-no-repeat shadow-lg transition-all duration-300 ease-in-out hover:shadow-xl"
Expand Down Expand Up @@ -50,7 +59,7 @@ export function Trigger() {

const handleHotkey = () => {
const activeElement = shadowRoot?.activeElement
if (isEditing || isActiveElementEditable(activeElement)) {
if (isEditing || isActiveElementEditable(activeElement ?? null)) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/content/components/setting/Shortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export function Shortcut() {
if (key.length === 1 || ['F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'].includes(key)) {
let processedKey = key.toLowerCase()

if (KOREAN_TO_ENGLISH[processedKey]) {
processedKey = KOREAN_TO_ENGLISH[processedKey]
if (KOREAN_TO_ENGLISH[processedKey as keyof typeof KOREAN_TO_ENGLISH]) {
processedKey = KOREAN_TO_ENGLISH[processedKey as keyof typeof KOREAN_TO_ENGLISH]
}

const newShortcut = [
Expand Down
2 changes: 1 addition & 1 deletion src/content/components/task/TaskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Video, FileText, CheckCircle, AlertTriangle, Clock, XCircle } from 'luc
import type { Activity } from '@/types'
import { cn } from '@/utils/cn'

const StatusBadge = ({ isExpired, hasSubmitted }) => {
const StatusBadge = ({ isExpired, hasSubmitted }: { isExpired: boolean; hasSubmitted: boolean }) => {
if (isExpired && !hasSubmitted) {
return (
<span className="flex items-center text-12px text-red-600">
Expand Down
2 changes: 1 addition & 1 deletion src/context/themeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ThemeContextValue<T = Theme> = {
setTheme: (theme: T) => void
}

export const ThemeContext = createContext<ThemeContextValue>(null)
export const ThemeContext = createContext<ThemeContextValue | null>(null)

export const useThemeContext = () => {
const context = useContext(ThemeContext)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cheerioUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const mapElement = <T>(elements: Cheerio<AnyNode>, callback: (i: number,
}

export const getText = ($el: Cheerio<AnyNode>): string => $el.text().trim()
export const getAttr = ($el: Cheerio<AnyNode>, attr: string): string => $el.attr(attr) || ''
export const getAttr = ($el: Cheerio<AnyNode>, attr: string): string | undefined => $el.attr(attr)
13 changes: 10 additions & 3 deletions src/utils/getLinkId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export function getLinkId(link: string) {
if (!link) return ''
return new URL(link).searchParams.get('id')
export function getLinkId(link?: string) {
if (link == null) {
return ''
}

try {
return new URL(link).searchParams.get('id') ?? ''
} catch {
return ''
}
}

0 comments on commit b4bda2d

Please sign in to comment.