fix sonar warnings

This commit is contained in:
Athou
2025-07-29 15:21:15 +02:00
parent 31e385fbfb
commit c3d4831550
69 changed files with 177 additions and 91 deletions

View File

@@ -1,4 +1,4 @@
import { TypographyStylesProvider } from "@mantine/core"
import { Typography } from "@mantine/core"
import type { ReactNode } from "react"
import { tss } from "@/tss"
@@ -20,5 +20,5 @@ const useStyles = tss.create(() => ({
export const BasicHtmlStyles = (props: { children: ReactNode }) => {
const { classes } = useStyles()
return <TypographyStylesProvider className={classes.content}>{props.children}</TypographyStylesProvider>
return <Typography className={classes.content}>{props.children}</Typography>
}

View File

@@ -1,7 +1,12 @@
import { BasicHtmlStyles } from "@/components/content/BasicHtmlStyles"
import { ImageWithPlaceholderWhileLoading } from "@/components/ImageWithPlaceholderWhileLoading"
export function Enclosure(props: { enclosureType: string; enclosureUrl: string }) {
export function Enclosure(
props: Readonly<{
enclosureType: string
enclosureUrl: string
}>
) {
const hasVideo = props.enclosureType.startsWith("video")
const hasAudio = props.enclosureType.startsWith("audio")
const hasImage = props.enclosureType.startsWith("image")

View File

@@ -96,7 +96,7 @@ const useStyles = tss
}
})
export function FeedEntry(props: FeedEntryProps) {
export function FeedEntry(props: Readonly<FeedEntryProps>) {
const viewMode = useAppSelector(state => state.user.localSettings.viewMode)
const fontSizePercentage = useAppSelector(state => state.user.localSettings.fontSizePercentage)
const { classes, cx } = useStyles({

View File

@@ -9,7 +9,7 @@ export interface FeedEntryBodyProps {
entry: Entry
}
export function FeedEntryBody(props: FeedEntryBodyProps) {
export function FeedEntryBody(props: Readonly<FeedEntryBodyProps>) {
const search = useAppSelector(state => state.entries.search)
return (
<Box>

View File

@@ -27,7 +27,7 @@ const useStyles = tss.create(({ theme, colorScheme }) => ({
},
}))
export function FeedEntryContextMenu(props: FeedEntryContextMenuProps) {
export function FeedEntryContextMenu(props: Readonly<FeedEntryContextMenuProps>) {
const colorScheme = useColorScheme()
const { classes } = useStyles()
const sourceType = useAppSelector(state => state.entries.source.type)

View File

@@ -14,7 +14,7 @@ interface FeedEntryFooterProps {
entry: Entry
}
export function FeedEntryFooter(props: FeedEntryFooterProps) {
export function FeedEntryFooter(props: Readonly<FeedEntryFooterProps>) {
const tags = useAppSelector(state => state.user.tags)
const mobile = useMobile()
const { spacing } = useActionButton()

View File

@@ -5,7 +5,7 @@ export interface FeedFaviconProps {
size?: number
}
export function FeedFavicon({ url, size = 18 }: FeedFaviconProps) {
export function FeedFavicon({ url, size = 18 }: Readonly<FeedFaviconProps>) {
return (
<ImageWithPlaceholderWhileLoading
src={url}

View File

@@ -12,7 +12,7 @@ export interface MediaProps {
description?: string
}
export function Media(props: MediaProps) {
export function Media(props: Readonly<MediaProps>) {
const width = props.thumbnailWidth
const height = props.thumbnailHeight
const placeholderSize = calculatePlaceholderSize({

View File

@@ -22,7 +22,15 @@ const useStyles = tss
},
}))
function ShareButton({ icon, color, onClick }: { icon: IconType; color: Color; onClick: () => void }) {
function ShareButton({
icon,
color,
onClick,
}: Readonly<{
icon: IconType
color: Color
onClick: () => void
}>) {
const { classes } = useStyles({
color,
})
@@ -36,7 +44,15 @@ function ShareButton({ icon, color, onClick }: { icon: IconType; color: Color; o
)
}
function SiteShareButton({ url, icon, color }: { icon: IconType; color: Color; url: string }) {
function SiteShareButton({
url,
icon,
color,
}: Readonly<{
icon: IconType
color: Color
url: string
}>) {
const onClick = () => {
window.open(url, "", "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600")
}
@@ -44,7 +60,11 @@ function SiteShareButton({ url, icon, color }: { icon: IconType; color: Color; u
return <ShareButton icon={icon} color={color} onClick={onClick} />
}
function CopyUrlButton({ url }: { url: string }) {
function CopyUrlButton({
url,
}: Readonly<{
url: string
}>) {
return (
<CopyButton value={url}>
{({ copied, copy }) => <ShareButton icon={copied ? TbCheck : TbCopy} color="#000" onClick={copy} />}
@@ -52,7 +72,13 @@ function CopyUrlButton({ url }: { url: string }) {
)
}
function BrowserNativeShareButton({ url, description }: { url: string; description: string }) {
function BrowserNativeShareButton({
url,
description,
}: Readonly<{
url: string
description: string
}>) {
const mobile = useMobile()
const { isBrowserExtensionPopup } = useBrowserExtension()
const onClick = () => {
@@ -71,7 +97,12 @@ function BrowserNativeShareButton({ url, description }: { url: string; descripti
)
}
export function ShareButtons(props: { url: string; description: string }) {
export function ShareButtons(
props: Readonly<{
url: string
description: string
}>
) {
const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
const enabledSharingSites = (Object.keys(Constants.sharing) as Array<keyof SharingSettings>).filter(site => sharingSettings?.[site])
const url = encodeURIComponent(props.url)

View File

@@ -39,9 +39,8 @@ export function Subscribe() {
},
})
const subscribe = useAsyncCallback(client.feed.subscribe, {
onSuccess: async sub => {
await dispatch(reloadTree())
dispatch(redirectToFeed(sub.data))
onSuccess: sub => {
dispatch(reloadTree()).then(() => dispatch(redirectToFeed(sub.data)))
},
})

View File

@@ -43,7 +43,7 @@ const useStyles = tss
},
}))
export function FeedEntryCompactHeader(props: FeedEntryHeaderProps) {
export function FeedEntryCompactHeader(props: Readonly<FeedEntryHeaderProps>) {
const { classes } = useStyles({
read: props.entry.read,
})

View File

@@ -24,7 +24,7 @@ const useStyles = tss
},
}))
export function FeedEntryHeader(props: FeedEntryHeaderProps) {
export function FeedEntryHeader(props: Readonly<FeedEntryHeaderProps>) {
const { classes } = useStyles({
read: props.entry.read,
})

View File

@@ -6,7 +6,7 @@ export interface FeedEntryTitleProps {
entry: Entry
}
export function FeedEntryTitle(props: FeedEntryTitleProps) {
export function FeedEntryTitle(props: Readonly<FeedEntryTitleProps>) {
const search = useAppSelector(state => state.entries.search)
const keywords = search?.split(" ")
return (

View File

@@ -6,7 +6,11 @@ import { markEntry } from "@/app/entries/thunks"
import { useAppDispatch } from "@/app/store"
import type { Entry } from "@/app/types"
export function OpenExternalLink(props: { entry: Entry }) {
export function OpenExternalLink(
props: Readonly<{
entry: Entry
}>
) {
const dispatch = useAppDispatch()
const onClick = (e: React.MouseEvent) => {
e.stopPropagation()

View File

@@ -6,7 +6,11 @@ import { starEntry } from "@/app/entries/thunks"
import { useAppDispatch } from "@/app/store"
import type { Entry } from "@/app/types"
export function Star(props: { entry: Entry }) {
export function Star(
props: Readonly<{
entry: Entry
}>
) {
const dispatch = useAppDispatch()
const onClick = (e: React.MouseEvent) => {
e.stopPropagation()