Skip to content

Commit

Permalink
fix: activity icon fallback
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Feb 7, 2024
1 parent d89cb1f commit f07f390
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/(app)/friends/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { toast } from '~/lib/toast'
import { useAggregationSelector } from '~/providers/root/aggregation-data-provider'

const renderTitle = (text: string) => {
return <h1 className="headline !mt-12 !text-xl">{text}</h1>
return <h1 className="headline !my-12 !text-xl">{text}</h1>
}

export default function Page() {
Expand Down
25 changes: 12 additions & 13 deletions src/components/layout/header/internal/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useQuery } from '@tanstack/react-query'
import React, { memo, useDeferredValue, useEffect, useMemo } from 'react'
import clsx from 'clsx'
import { AnimatePresence, m } from 'framer-motion'
import Image from 'next/image'

Expand Down Expand Up @@ -288,33 +289,31 @@ export const Activity = memo(() => {
})
Activity.displayName = 'Activity'
const cMusicProps = { processName: 'cmusic' }

const ErrorFallback = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAMAAAAKE/YAAAAAKlBMVEVHcEzl5+5tfLgMEWLl6PD2+PrN0uL29/ry8/jV4ubT4OX////Z5enk7O8l7W0nAAAACXRSTlMAhBswYvlC2bg7dL5eAAAIE0lEQVR42u2di5aiOhBFB5ogRyv//7sXacYjVB4mFeHOWpyxbTVQ2dYUeZGk/1y6dOnSpUuXLl26dOlSSn0/juMQVPf76PRjTQpqnNV/j3ccuul2c7MeDTWbu91uU9cRvR3wdNtlFsifn+ZTtA03dWND5GFyj0PkpqEV8u1xoG4tsMfpcaTcjG0Okm4xdLAmq5tPkDM5e3SPk+SqI3s4HpaRPVQzO2Vtls/IqbcZhaqrSupRAXvBfS9s3ggEOgmAAKGTKPGuAXXvtn72cg9IZCWQp7BL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HOLt4iVGq2CHUbX6ngyFHvNhd2oTDEa1tVfLQZq4BnRZGpUTFnXa22F/ZeQtwUIADflW17K36fX6eDI0/dPZTetxeW+cEX4vMSLzxN1A7DRmZSu8cxsjMzQv4hZlKPt3N2zPYDmcupf6ZTNoL/IXMV9XC4s28dmeuoZ+zuUGz3RCZzrbNn7Mmt0fY1rRnMXqabrdjjzL3Pw6lfrwQ+Nm/3B9MLK/HwY3czY2TW6y+jMJuGfxxl6oZxISZyG+4FfRyGrqmGcRxX4yRux72Qt9fKSyc35p7Jv6PZ9Gnq/1y6dOnSpUuXLl26VKn/ACOMK7nwUEF/AAAAAElFTkSuQmCC`
const TriggerComponent = memo<{
processName: string
icon?: string
}>(({ processName, icon }) => {
const isBuiltIn = !!appLabels[processName]

if (!isBuiltIn) {
return (
<img
width={32}
height={32}
src={icon}
alt={processName}
className="pointer-events-none select-none overflow-hidden rounded-md"
/>
)
}
const src = !isBuiltIn && icon ? icon : `/apps/${appLabels[processName]}.png`

const className = clsx('pointer-events-none select-none', {
'rounded-md': !isBuiltIn,
})
const [error, setError] = React.useState(false)

return (
<Image
width={32}
height={32}
src={`/apps/${appLabels[processName]}.png`}
src={error ? ErrorFallback : src}
alt={processName}
priority
fetchPriority="low"
className="pointer-events-none select-none"
className={className}
onError={() => setError(true)}
/>
)
})
Expand Down

0 comments on commit f07f390

Please sign in to comment.