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 Minor Issues #406

Merged
merged 3 commits into from
Apr 18, 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
5 changes: 3 additions & 2 deletions src/components/main/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,15 @@ const TabsHomePage = ({
})

const isLoadingFollowedIds = followedIds === undefined
const hasFollowers = (followedIds?.length ?? 0) > 0
useEffect(() => {
if (!isInitialized || !isSignedIn || isLoadingFollowedIds) return
if (followedIds.length === 0) {
if (!hasFollowers) {
setFiltersInUrl(router, 'posts', { type: 'hot' }, { ref: refId })
} else {
onChangeKey(tab)
}
}, [followedIds, isInitialized])
}, [hasFollowers, isInitialized])

const handleScroll = () => {
const currentScrollPos = window.pageYOffset
Expand Down
12 changes: 7 additions & 5 deletions src/components/onboarding/RecommendedSpacesOnboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ export default function RecommendedSpacesOnboarding() {
const isMobile = useIsMobileWidthOrDevice()
const sendEvent = useSendEvent()
const isInitializedProxy = useMyAccount(state => state.isInitializedProxy)
const { data: isFinishedOnBoarding, setData: setIsFinishedOnBoarding } =
useBooleanExternalStorage(ON_BOARDING_MODAL_KEY, {
const { getDataForAddress, setData: setIsFinishedOnBoarding } = useBooleanExternalStorage(
ON_BOARDING_MODAL_KEY,
{
storageKeyType: 'user',
})
},
)
const { setIsOnBoardingSkipped } = useIsOnBoardingSkippedContext()
const { api } = useSubsocialApi()

Expand All @@ -38,8 +40,8 @@ export default function RecommendedSpacesOnboarding() {
const [isOpen, setIsOpen] = useState(false)

useEffect(() => {
if (isInitializedProxy && !isFinishedOnBoarding && myAddress) setIsOpen(true)
}, [myAddress, isInitializedProxy, isFinishedOnBoarding])
if (isInitializedProxy && !getDataForAddress(myAddress) && myAddress) setIsOpen(true)
}, [myAddress, isInitializedProxy])

const closeModal = () => {
sendEvent('login_space_suggestion_skipped')
Expand Down
6 changes: 6 additions & 0 deletions src/components/posts/share/ShareModal/index.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
.DfShareModalMdEditor
.CodeMirror
height: 5rem

.EditorContainer
padding: $space_small
padding-top: $space_mini
border: 1px solid $color_border
border-radius: $border_radius_normal
21 changes: 12 additions & 9 deletions src/components/posts/share/ShareModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dynamic from 'next/dynamic'
import { useEffect, useState } from 'react'
import { Controller, ErrorMessage, useForm } from 'react-hook-form'
import { useMyAddress } from 'src/components/auth/MyAccountsContext'
import { htmlToMd } from 'src/components/editor/tiptap'
import { TxCallback, TxFailedCallback } from 'src/components/substrate/SubstrateTxButton'
import {
useCreateReloadPost,
Expand All @@ -17,9 +18,9 @@ import { IpfsCid, PostId, SharedPostContent, SpaceId } from 'src/types'
import { CreateSpaceButton } from '../../../spaces/helpers'
import { getNewIdFromEvent, getTxParams } from '../../../substrate'
import { useSubsocialApi } from '../../../substrate/SubstrateContext'
import DfMdEditor from '../../../utils/DfMdEditor'
import { MyAccountProps } from '../../../utils/MyAccount'
import SelectSpacePreview from '../../../utils/SelectSpacePreview'
import HtmlEditor from '../../editor/HtmlEditor'
import { buildSharePostValidationSchema } from '../../PostValidation'
import { PublicPostPreviewById } from '../../PublicPostPreview'
import styles from './index.module.sass'
Expand Down Expand Up @@ -82,7 +83,7 @@ const InnerSharePostModal = (props: Props) => {
disabled={isSubmitting}
params={() =>
getTxParams({
json: { body } as SharedPostContent,
json: { body: htmlToMd(body) } as SharedPostContent,
buildTxParamsCallback: newTxParams,
setIpfsCid,
ipfs,
Expand Down Expand Up @@ -138,13 +139,15 @@ const InnerSharePostModal = (props: Props) => {
</span>

<form style={{ margin: '1rem 0' }}>
<Controller
control={control}
as={<DfMdEditor options={{ autofocus: true }} />}
name={Fields.body}
value={body}
className={`${errors[Fields.body] && 'error'} ${styles.DfShareModalMdEditor}`}
/>
<div className={styles.EditorContainer}>
<Controller
control={control}
as={<HtmlEditor autoFocus showToolbar />}
name={Fields.body}
value={body}
className={`${errors[Fields.body] && 'error'} ${styles.DfShareModalMdEditor}`}
/>
</div>
<div className='DfError'>
<ErrorMessage errors={errors} name={Fields.body} />
</div>
Expand Down
Loading