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: channel cover picture upload #508

Merged
merged 3 commits into from
Dec 28, 2022
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
7 changes: 5 additions & 2 deletions apps/web/src/components/Channel/BasicInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import type { FC } from 'react'
import React, { useState } from 'react'
import { FiSettings } from 'react-icons/fi'
import { Analytics, TRACK } from 'utils'
import getCoverPicture from 'utils/functions/getCoverPicture'
import getChannelCoverPicture from 'utils/functions/getChannelCoverPicture'
import getProfilePicture from 'utils/functions/getProfilePicture'
import imageCdn from 'utils/functions/imageCdn'
import sanitizeIpfsUrl from 'utils/functions/sanitizeIpfsUrl'

import MutualSubscribers from '../Mutual/MutualSubscribers'

Expand Down Expand Up @@ -43,7 +44,9 @@ const BasicInfo: FC<Props> = ({ channel }) => {
<span>
<div
style={{
backgroundImage: `url(${imageCdn(getCoverPicture(channel))})`
backgroundImage: `url(${imageCdn(
sanitizeIpfsUrl(getChannelCoverPicture(channel))
)})`
}}
className="absolute w-full bg-white bg-center bg-no-repeat bg-cover rounded-lg dark:bg-gray-900 h-44 md:h-72"
>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Settings/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
TRACK
} from 'utils'
import { VERIFIED_CHANNELS } from 'utils/data/verified'
import getCoverPicture from 'utils/functions/getCoverPicture'
import getChannelCoverPicture from 'utils/functions/getChannelCoverPicture'
import { getValueFromKeyInAttributes } from 'utils/functions/getFromAttributes'
import imageCdn from 'utils/functions/imageCdn'
import omitKey from 'utils/functions/omitKey'
Expand Down Expand Up @@ -85,7 +85,7 @@ const BasicInfo = ({ channel }: Props) => {
const [copy] = useCopyToClipboard()
const [loading, setLoading] = useState(false)
const [uploading, setUploading] = useState(false)
const [coverImage, setCoverImage] = useState(getCoverPicture(channel))
const [coverImage, setCoverImage] = useState(getChannelCoverPicture(channel))
const selectedChannel = useAppStore((state) => state.selectedChannel)

const {
Expand Down Expand Up @@ -272,13 +272,13 @@ const BasicInfo = ({ channel }: Props) => {
src={
sanitizeIpfsUrl(coverImage) ??
imageCdn(
sanitizeIpfsUrl(channel?.coverPicture?.original?.url),
sanitizeIpfsUrl(getChannelCoverPicture(channel)),
'thumbnail'
)
}
className="object-cover object-center w-full h-48 bg-white rounded-xl md:h-56 dark:bg-gray-900"
draggable={false}
alt={`${channel.handle} Cover`}
alt={`${channel.handle}'s cover`}
/>
<label
htmlFor="chooseCover"
Expand Down
11 changes: 11 additions & 0 deletions packages/utils/functions/getChannelCoverPicture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Profile } from 'lens'

import { STATIC_ASSETS } from '../constants'

const getChannelCoverPicture = (channel: Profile): string => {
return channel.coverPicture && channel.coverPicture.__typename === 'MediaSet'
? channel?.coverPicture?.original?.url
: `${STATIC_ASSETS}/images/coverGradient.jpeg`
}

export default getChannelCoverPicture
14 changes: 0 additions & 14 deletions packages/utils/functions/getCoverPicture.ts

This file was deleted.