Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx image stacker issue #425

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions apps/web/src/pages/api/renderer/stack-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
images.map((imageUrl) => getImageData(imageUrl))
)

const isSvg = images[0].includes('.svg')

// Resize all SVGs to a default size
if (isSvg) {
imageData = await Promise.all(
imageData.map(async (x) =>
sharp(x).resize(SVG_DEFAULT_SIZE, SVG_DEFAULT_SIZE, { fit: 'inside' }).toBuffer()
)
// Resize all images to a default size
imageData = await Promise.all(
imageData.map(async (x) =>
sharp(x).resize(SVG_DEFAULT_SIZE, SVG_DEFAULT_SIZE, { fit: 'inside' }).toBuffer()
)
}
)

const compositeParams = imageData.slice(1).map((x) => ({
input: x,
Expand Down
14 changes: 8 additions & 6 deletions apps/web/src/pages/dao/[network]/[token]/[tokenId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Meta } from 'src/components/Meta'
import AnimatedModal from 'src/components/Modal/AnimatedModal'
import { SuccessModalContent } from 'src/components/Modal/SuccessModalContent'
import { CACHE_TIMES } from 'src/constants/cacheTimes'
import { PUBLIC_DEFAULT_CHAINS } from 'src/constants/defaultChains'
import { PUBLIC_ALL_CHAINS, PUBLIC_DEFAULT_CHAINS } from 'src/constants/defaultChains'
import { CAST_ENABLED } from 'src/constants/farcasterEnabled'
import { SUCCESS_MESSAGES } from 'src/constants/messages'
import { SDK } from 'src/data/subgraph/client'
Expand All @@ -27,38 +27,40 @@ import { DaoTopSection } from 'src/modules/dao/components/DaoTopSection'
import FeedTab from 'src/modules/dao/components/Feed/Feed'
import { NextPageWithLayout } from 'src/pages/_app'
import { DaoOgMetadata } from 'src/pages/api/og/dao'
import { AddressType, Chain } from 'src/typings'
import { AddressType, CHAIN_ID, Chain } from 'src/typings'
import { isPossibleMarkdown } from 'src/utils/helpers'

export type TokenWithDao = NonNullable<TokenWithDaoQuery['token']>

interface TokenPageProps {
url: string
chain: Chain
collection: AddressType
token: TokenWithDao
name: string
description: string
tokenId: string
addresses: DaoContractAddresses
ogImageURL: string
chainId: CHAIN_ID
}

const TokenPage: NextPageWithLayout<TokenPageProps> = ({
url,
chain,
collection,
token,
description,
name,
addresses,
ogImageURL,
chainId,
}) => {
const { query, replace, pathname } = useRouter()
const { address } = useAccount()

const chain = PUBLIC_ALL_CHAINS.find((x) => x.id === chainId) as Chain

const { hasThreshold } = useVotes({
chainId: chain.id,
chainId: chainId,
signerAddress: address,
collectionAddress: collection,
governorAddress: addresses?.governor,
Expand Down Expand Up @@ -240,14 +242,14 @@ export const getServerSideProps: GetServerSideProps = async ({

const props: TokenPageProps = {
url: resolvedUrl,
chain,
collection,
name,
token,
description: description || '',
tokenId,
addresses,
ogImageURL,
chainId: chain.id,
}

return {
Expand Down
Loading