Skip to content

Commit

Permalink
Merge branch 'develop' into feat/tabs-boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwoz committed Sep 2, 2024
2 parents 33654bb + eecdd36 commit 2a00449
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
16 changes: 6 additions & 10 deletions src/components/Editor/SetCover/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ASSET_TYPE,
ENTITY_TYPE,
} from '~/common/enums'
import { sleep, validateImage } from '~/common/utils'
import { validateImage } from '~/common/utils'
import {
DraftDetailStateContext,
Icon,
Expand Down Expand Up @@ -55,13 +55,14 @@ const Uploader: React.FC<UploaderProps> = ({

const [upload, { loading }] = useMutation<DirectImageUploadMutation>(
DIRECT_IMAGE_UPLOAD,
undefined,
{ showToast: false }
)
const [directImageUploadDone] = useMutation<DirectImageUploadDoneMutation>(
DIRECT_IMAGE_UPLOAD_DONE,
{
update: async (cache, { data }) => {
if (data?.directImageUpload) {
// FIXME: newly uploaded images will return 404 in a short time
// https://community.cloudflare.com/t/new-uploaded-images-need-about-10-min-to-display-in-my-website/121568
await sleep(300)

updateDraftAssets({
cache,
id: entityId,
Expand All @@ -72,11 +73,6 @@ const Uploader: React.FC<UploaderProps> = ({
},
{ showToast: false }
)
const [directImageUploadDone] = useMutation<DirectImageUploadDoneMutation>(
DIRECT_IMAGE_UPLOAD_DONE,
undefined,
{ showToast: false }
)
const { upload: uploadImage, uploading } = useDirectImageUpload()

const { isInPath } = useRoute()
Expand Down
2 changes: 0 additions & 2 deletions src/components/SquareTabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export const SquareTabs: React.FC<React.PropsWithChildren<SquareTabsProps>> & {
const [scrollLeft, setScrollLeft] = useState(0)

const isTabsOverflowing = () => {
const $nav = navRef.current
const $container = containerRef.current
if (!$nav || !$container) return false
return $nav.scrollWidth > $container.clientWidth
}
Expand Down
6 changes: 5 additions & 1 deletion src/views/ArticleDetail/Edit/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery } from '@apollo/react-hooks'
import _omit from 'lodash/omit'
import dynamic from 'next/dynamic'
import { useContext, useState } from 'react'
import { useContext, useEffect, useState } from 'react'

import {
ASSET_TYPE,
Expand Down Expand Up @@ -86,6 +86,10 @@ const BaseEdit = ({ article }: { article: Article }) => {

// cover
const [assets, setAssets] = useState(article.assets || [])

useEffect(() => {
setAssets(article.assets || [])
}, [article.assets])
const [cover, setCover] = useState<AssetFragment | undefined>(
assets.find((asset) => asset.path === article.cover)
)
Expand Down
3 changes: 2 additions & 1 deletion src/views/MomentDetail/Edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CLEAR_MOMENT_FORM, MAX_MOMENT_CONTENT_LENGTH } from '~/common/enums'
import {
formStorage,
parseFormSubmitErrors,
sanitizeContent,
stripHtml,
toPath,
} from '~/common/utils'
Expand Down Expand Up @@ -84,7 +85,7 @@ const Edit = () => {
const { data } = await putMoment({
variables: {
input: {
content,
content: sanitizeContent(content),
assets: assets.map(({ assetId }) => assetId),
},
},
Expand Down

0 comments on commit 2a00449

Please sign in to comment.