Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.32.1",
"version": "2.32.2",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ function Content(props: ProfileTabContentProps) {
return plugins
.flatMap((x) => x.ProfileTabs?.map((y) => ({ ...y, pluginID: x.ID })) || [])
.filter((x) => {
const shouldDisplay =
x.Utils?.shouldDisplay?.(currentVisitingSocialIdentity, selectedSocialAccount) ?? true
return x.pluginID !== PluginID.NextID && shouldDisplay
if (x.pluginID === PluginID.NextID) return false
return x.Utils?.shouldDisplay?.(currentVisitingSocialIdentity, selectedSocialAccount) ?? true
})
.sort((a, z) => a.priority - z.priority)
})
Expand All @@ -199,7 +198,7 @@ function Content(props: ProfileTabContentProps) {
id: x.ID,
label: typeof x.label === 'string' ? x.label : translate(x.label),
}))
}, [activatedPlugins, translate])
}, [activatedPlugins, translate, selectedSocialAccount])

const [currentTab, onChange] = useTabs(first(tabs)?.id ?? PluginID.Collectible, ...tabs.map((tab) => tab.id))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function resolveCurrentVisitingIdentityInner(
const domAvatar = document.querySelector(`a[href="/${handle}/photo"] img`)
// DOM avatar is more accurate, avatar from api could be outdate
const avatar = domAvatar?.getAttribute('src') || legacy.profile_image_url_https
const bio = legacy.profile_image_url_https
const bio = legacy.description
const homepage = legacy.entities.url?.urls?.[0]?.expanded_url

ref.value = {
Expand Down
37 changes: 35 additions & 2 deletions packages/plugins/RedPacket/src/SiteAdaptor/RedPacket/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { msg } from '@lingui/core/macro'
import { useLingui } from '@lingui/react'
import { Trans } from '@lingui/react/macro'
import { Icons } from '@masknet/icons'
import { usePostInfoDetails, usePostLink } from '@masknet/plugin-infra/content-script'
import { share } from '@masknet/plugin-infra/content-script/context'
import { LoadingStatus, TransactionConfirmModal } from '@masknet/shared'
Expand All @@ -12,16 +14,17 @@ import { EVMChainResolver } from '@masknet/web3-providers'
import { RedPacketStatus, type RedPacketJSONPayload } from '@masknet/web3-providers/types'
import { TokenType, formatBalance, isZero, minus } from '@masknet/web3-shared-base'
import { ChainId } from '@masknet/web3-shared-evm'
import { Card, Grow } from '@mui/material'
import { Card, Grow, Link } from '@mui/material'
import { memo, useCallback, useMemo, useState } from 'react'
import { RedPacketEnvelope } from '../components/RedPacketEnvelope.js'
import { Conditions } from '../Conditions/index.js'
import { useAvailabilityComputed } from '../hooks/useAvailabilityComputed.js'
import { useClaimCallback } from '../hooks/useClaimCallback.js'
import { useIsFireflyRedpacket } from '../hooks/useIsFireflyRedpacket.js'
import { useRedPacketContract } from '../hooks/useRedPacketContract.js'
import { useRedPacketCover } from '../hooks/useRedPacketCover.js'
import { useRefundCallback } from '../hooks/useRefundCallback.js'
import { OperationFooter } from './OperationFooter.js'
import { useRedPacketCover } from '../hooks/useRedPacketCover.js'

const useStyles = makeStyles()((theme) => {
return {
Expand All @@ -47,6 +50,18 @@ const useStyles = makeStyles()((theme) => {
},
footer: {
margin: theme.spacing(2),
display: 'flex',
height: 40,
gap: theme.spacing(0.5),
alignItems: 'center',
justifyContent: 'center',
borderRadius: 99,
fontSize: 14,
fontWeight: 700,
backgroundColor: theme.palette.maskColor.dark,
color: 'white',
cursor: 'pointer',
textDecoration: 'none !important',
},
envelope: {
height: '100%',
Expand Down Expand Up @@ -96,6 +111,8 @@ export const RedPacket = memo(function RedPacket({ payload, currentPluginID }: R
const postUrl = usePostInfoDetails.url()
const handle = usePostInfoDetails.handle()
const link = postLink.toString() || postUrl?.toString()
const isFireflyRedpacket = useIsFireflyRedpacket()
const postId = usePostInfoDetails.postID()

// TODO payload.chainId is undefined on production mode
const network = useNetwork<NetworkPluginID.PLUGIN_EVM>(
Expand Down Expand Up @@ -225,6 +242,22 @@ export const RedPacket = memo(function RedPacket({ payload, currentPluginID }: R

if (outdated) return card

if (isFireflyRedpacket) {
return (
<>
{card}
<Link
className={classes.footer}
href={`https://firefly.mask.social/post/twitter/${postId}`}
target="_blank"
rel="noreferrer noopener">
<Icons.LinkOut size={18} />
<Trans>Claim on Firefly</Trans>
</Link>
</>
)
}

return (
<>
{card}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export function useAvailability(
queryKey: ['red-packet', 'check-availability', chainId, version, id, account],
queryFn: async () => {
if (!id || !redPacketContract) return null
return redPacketContract.methods.check_availability(id).call({
const availability = await redPacketContract.methods.check_availability(id).call({
// check availability is ok w/o account
from: account,
})
return availability
},
refetchInterval(query) {
const { data } = query.state
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { usePostInfoDetails } from '@masknet/plugin-infra/content-script'

export function useIsFireflyRedpacket() {
const raw = usePostInfoDetails.rootNode()?.textContent

return raw?.includes('#FireflyLuckyDrop') || false
}
1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/en-US.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/plugins/RedPacket/src/locale/en-US.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/ja-JP.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/plugins/RedPacket/src/locale/ja-JP.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/ko-KR.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/plugins/RedPacket/src/locale/ko-KR.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/zh-CN.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/plugins/RedPacket/src/locale/zh-CN.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/zh-TW.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/plugins/RedPacket/src/locale/zh-TW.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions packages/theme/src/Components/CountdownButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { makeStyles } from '../../entry-base.js'

const useStyles = makeStyles()({
button: {
whiteSpace: 'nowrap',
'&:hover': {
background: 'transparent',
},
Expand All @@ -15,7 +16,7 @@ export interface CountdownButtonProps extends ButtonProps {
}

export function CountdownButton(props: CountdownButtonProps) {
const { classes } = useStyles()
const { classes, cx } = useStyles()
const { duration = 60, children, repeatContent = 'Resend', onClick, disabled, ...others } = props
const [countdown, setCountdown] = useState<number | undefined>(undefined)
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
Expand All @@ -29,7 +30,7 @@ export function CountdownButton(props: CountdownButtonProps) {
else
return (
<>
{children} (${countdown})
{children} ({countdown})
</>
)
} else if (countdown === 0) {
Expand All @@ -55,7 +56,7 @@ export function CountdownButton(props: CountdownButtonProps) {
return (
<Button
{...others}
className={classes.button}
className={cx(classes.button, others.className)}
onClick={handleClick}
disabled={!!countdown || disabled}
disableRipple
Expand Down