Skip to content

Commit

Permalink
Merge pull request #162 from dappforce/deploy/active-staking
Browse files Browse the repository at this point in the history
Active Staking Fixes
  • Loading branch information
olehmell authored Jan 10, 2024
2 parents 2654ff6 + bce565f commit 6096836
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/components/creators/CreatorDashboardSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function PostPageSidebar({ space }: Extract<CreatorDashboardSidebarType, { name:

return (
<>
<CreatorInfoCard showStakeButton={!data?.hasStaked} space={space} />
<CreatorInfoCard showStakeButton={data?.hasStaked} space={space} />
{!loadingTotalStake &&
(data?.hasStaked ? (
<>
Expand Down
79 changes: 47 additions & 32 deletions src/components/creators/cards/CreatorInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { BsBoxArrowUpRight } from 'react-icons/bs'
import { useMyAddress } from 'src/components/auth/MyAccountsContext'
import { FormatBalance } from 'src/components/common/balances'
import { SpaceFollowersModal } from 'src/components/profiles/AccountsListModal'
import { OfficialSpaceStatus, SpaceAvatar } from 'src/components/spaces/helpers'
import { OfficialSpaceStatus, SpaceAvatar, useIsMySpace } from 'src/components/spaces/helpers'
import ViewSpaceLink from 'src/components/spaces/ViewSpaceLink'
import CollapsibleParagraph from 'src/components/utils/CollapsibleParagraph/CollapsibleParagraph'
import FollowSpaceButton from 'src/components/utils/FollowSpaceButton'
import { Pluralize } from 'src/components/utils/Plularize'
Expand All @@ -29,16 +30,25 @@ export default function CreatorInfoCard({ space, showStakeButton = true }: Creat
const { data: stakeData } = useFetchStakeData(myAddress, space.id)
const { data: totalStake } = useFetchTotalStake(myAddress)
const sendEvent = useSendEvent()
const isMySpace = useIsMySpace(space.struct)

const shouldShowStakeButton = isCreatorSpace && showStakeButton
const shouldShowFollowButton = !isMySpace

return (
<Segment className={clsx(styles.CreatorInfoCard)}>
<div className={styles.TitleContainer}>
<SpaceAvatar noMargin space={space?.struct} size={44} avatar={space?.content?.image} />
<div className='d-flex flex-column'>
<span className={styles.Title}>
<span>{space.content?.name ?? 'Untitled'}</span>
<OfficialSpaceStatus withoutContainer space={space.struct} />
</span>
<ViewSpaceLink
space={space.struct}
title={
<span className={styles.Title}>
<span>{space.content?.name ?? 'Untitled'}</span>
<OfficialSpaceStatus withoutContainer space={space.struct} />
</span>
}
/>
<SpaceFollowersModal
address={space.id}
pluralizeTitle='Follower'
Expand All @@ -54,34 +64,39 @@ export default function CreatorInfoCard({ space, showStakeButton = true }: Creat
</div>
<CollapsibleParagraph className='FontSmall mb-2' text={space.content?.about ?? ''} />
{!stakeData?.hasStaked ? (
<div className='GapSmall d-flex flex-column mt-2'>
{isCreatorSpace && showStakeButton && (
<Button
target='_blank'
type='primary'
href={getSubIdCreatorsLink(space)}
onClick={() =>
sendEvent('astake_banner_add_stake', {
eventSource: 'creator-info-banner',
spaceId: space.id,
})
}
>
Stake
</Button>
)}
<div
onClick={() =>
sendEvent('follow', {
spaceId: space.id,
eventSource: 'post',
amountRange: getAmountRange(totalStake?.amount),
})
}
>
<FollowSpaceButton space={space.struct} />
(shouldShowFollowButton || shouldShowStakeButton) && (
<div className={clsx('GapSmall d-flex flex-column mt-2')}>
{shouldShowStakeButton && (
<Button
target='_blank'
type='primary'
href={getSubIdCreatorsLink(space)}
onClick={() =>
sendEvent('astake_banner_add_stake', {
eventSource: 'creator-info-banner',
spaceId: space.id,
})
}
>
Stake
</Button>
)}
{shouldShowFollowButton && (
<div
className='w-100'
onClick={() =>
sendEvent('follow', {
spaceId: space.id,
eventSource: 'post',
amountRange: getAmountRange(totalStake?.amount),
})
}
>
<FollowSpaceButton className='w-100' space={space.struct} />
</div>
)}
</div>
</div>
)
) : (
<div className={clsx('d-flex flex-column GapNormal', styles.MyStake)}>
<div className='GapSmall d-flex align-items-center justify-content-between FontSmall'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function CreatorRewardInfoCard() {
<div className='d-flex align-items-center justify-content-between'>
<div className='d-flex align-items-baseline GapMini'>
<MutedSpan>Distribution in</MutedSpan>
<Tooltip title='How long until you will receive your creator rewards for this week'>
<Tooltip title='The amount of time remaining until your bonus rewards for this week are deposited into your account'>
<SlQuestion className='FontTiny ColorMuted' />
</Tooltip>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/creators/staker-rewards/StakerRewardInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export default function StakerRewardInfo({ size, ...props }: StakerRewardInfoPro
reward the authors of the posts you like.
</p>
<p className='mb-0'>
If you like more than 10, those author rewards will then be distributed among
more authors, resulting in each author receiving fewer rewards.
Liking more than 10 posts will spread the author rewards across more authors,
resulting in each author receiving fewer rewards.
</p>
</>
}
Expand Down Expand Up @@ -140,7 +140,7 @@ export default function StakerRewardInfo({ size, ...props }: StakerRewardInfoPro
<div className='d-flex justify-content-between align-items-center'>
<div className='d-flex align-items-baseline GapMini'>
<MutedSpan>Distribution in</MutedSpan>
<Tooltip title='How long until you will receive your bonus staking rewards for this week'>
<Tooltip title='The amount of time remaining until your bonus rewards for this week are deposited into your account'>
<SlQuestion className='FontTiny ColorMuted' />
</Tooltip>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/statistics/Statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ActivityEvent =
| 'SpaceFollowed'
| 'PostCreated'
| 'PostShared,CommentShared'
| 'CommentCreated,CommentReplyCreated'
// | 'CommentCreated,CommentReplyCreated'
| 'PostReactionCreated,CommentReactionCreated'
| 'AccountFollowed'

Expand All @@ -28,7 +28,7 @@ export const eventArr = [
'SpaceFollowed',
'PostCreated',
'PostShared,CommentShared',
'CommentCreated,CommentReplyCreated',
// 'CommentCreated,CommentReplyCreated',
'PostReactionCreated,CommentReactionCreated',
'AccountFollowed',
]
Expand Down
3 changes: 1 addition & 2 deletions src/components/voting/SuperLike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export default function SuperLike({ post, ...props }: SuperLikeProps) {
)

let tooltipTitle = ''
if (isPostCreatedMoreThan1Week)
tooltipTitle = 'You cannot super like posts that are older than 7 days'
if (isPostCreatedMoreThan1Week) tooltipTitle = 'You cannot like posts that are older than 7 days'
else if (isMyPost) tooltipTitle = 'You cannot like your own post'

const button = (
Expand Down

0 comments on commit 6096836

Please sign in to comment.