Skip to content

Commit

Permalink
fix: mf-6479 mf-6583 redpacket sender (#12068)
Browse files Browse the repository at this point in the history
* fix: mf-6479 mf-6583 redpacket sender

* fix: collection name overflow
  • Loading branch information
swkatmask authored Jan 23, 2025
1 parent 1e95708 commit 1197c50
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/plugin-infra/src/entry-content-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export {
useCurrentPersonaInformation,
useCurrentVisitingIdentity,
useCurrentVisitingSocialIdentity,
getLastRecognizedIdentity,
useLastRecognizedIdentity,
useLastRecognizedSocialIdentity,
usePostLink,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ import { lastRecognizedProfile } from './context.js'
export function useLastRecognizedIdentity() {
return useSubscription(lastRecognizedProfile ?? UNDEFINED)
}

export function getLastRecognizedIdentity() {
return lastRecognizedProfile.getCurrentValue()
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const useStyles = makeStyles()((theme) => {
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
},
tokenIcon: {
width: 24,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { t } from '@lingui/core/macro'
import { useLastRecognizedIdentity } from '@masknet/plugin-infra/content-script'
import { useCurrentLinkedPersona } from '@masknet/shared'
import { EMPTY_LIST, type NetworkPluginID } from '@masknet/shared-base'
import { useChainContext } from '@masknet/web3-hooks-base'
import { EVMChainResolver } from '@masknet/web3-providers'
Expand Down Expand Up @@ -141,9 +140,7 @@ export const RedPacketProvider = memo(function RedPacketProvider({ children }: P
const [token = nativeToken, setToken] = useState<FungibleToken<ChainId, SchemaType>>()

const myIdentity = useLastRecognizedIdentity()
const linkedPersona = useCurrentLinkedPersona()

const creator = myIdentity?.identifier?.userId || linkedPersona?.nickname || 'Unknown User'
const creator = myIdentity?.identifier?.userId || 'Unknown User'

const amount = rightShift(rawAmount || '0', token?.decimals)
const totalAmount = useMemo(() => multipliedBy(amount, isRandom ? 1 : (shares ?? '0')), [amount, shares, isRandom])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isNativeTokenAddress, useRedPacketConstants, type GasConfig } from '@ma
import { BigNumber } from 'bignumber.js'
import { useCallback, useEffect, useMemo, useRef } from 'react'
import { useCreateCallback, useCreateParams, type RedPacketSettings } from './useCreateCallback.js'
import { getLastRecognizedIdentity } from '@masknet/plugin-infra/content-script'

export function useCreateFTRedpacketCallback(
redpacketPubkey: string,
Expand Down Expand Up @@ -78,10 +79,11 @@ export function useCreateFTRedpacketCallback(

// the events log is not available
if (!events?.CreationSuccess?.returnValues.id) return
const senderName = settings.name || getLastRecognizedIdentity()?.identifier?.userId
const redpacketPayload = {
sender: {
address: account,
name: settings.name,
name: senderName,
message: settings.message,
},
is_random: settings.isRandom,
Expand Down

0 comments on commit 1197c50

Please sign in to comment.