Skip to content

Commit

Permalink
fix: mf-5559 tip button in reply photo tweet (#11057)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill authored and guanbinrui committed Oct 31, 2023
1 parent d0f2496 commit 4c3bb2b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
7 changes: 2 additions & 5 deletions packages/mask/src/site-adaptors/twitter.com/utils/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ export const postsContentSelector = () =>
querySelectorAll(
[
// tweets on timeline page
'[data-testid="tweet"] div + div div[lang]',
'[data-testid="tweet"] div + div div[data-testid="card.wrapper"]',
'[data-testid="tweet"] [data-testid="tweetText"]',
'[data-testid="tweet"]:not(:has([data-testid="tweetText"])) [data-testid="tweetPhoto"]', // tweets with only image.

// tweets on detailed page
'[data-testid="tweet"] + div > div:first-child div[lang]',
Expand All @@ -170,9 +170,6 @@ export const postsContentSelector = () =>
'[data-testid="tweet"] [aria-labelledby] div[role="link"] div[lang]',
// quoted tweets in detail page
'[data-testid="tweet"] > div:last-child div[role="link"] div[lang]',

// reply-tweets
'[data-testid="tweet"] + div div div[lang][dir]',
].join(','),
)

Expand Down
16 changes: 9 additions & 7 deletions packages/plugins/Tips/src/components/TipsButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Icons } from '@masknet/icons'
import {
PostInfoContext,
useCurrentVisitingIdentity,
useSocialIdentityByUserId,
} from '@masknet/plugin-infra/content-script'
import {
EMPTY_LIST,
NetworkPluginID,
Expand All @@ -9,15 +14,11 @@ import {
import { makeStyles } from '@masknet/theme'
import type { Web3Helper } from '@masknet/web3-helpers'
import { useNetworkContext } from '@masknet/web3-hooks-base'
import { useCallback, useEffect, useMemo, type HTMLProps, type MouseEventHandler, useContext } from 'react'
import { useCallback, useContext, useEffect, useMemo, type HTMLProps, type MouseEventHandler } from 'react'
import { useLocation } from 'react-use'
import { useProfilePublicKey } from '../../hooks/useProfilePublicKey.js'
import { PluginTipsMessages } from '../../messages.js'
import { useTipsAccounts } from './useTipsAccounts.js'
import {
PostInfoContext,
useCurrentVisitingIdentity,
useSocialIdentityByUserId,
} from '@masknet/plugin-infra/content-script'

interface Props extends HTMLProps<HTMLDivElement> {
// This is workaround solution, link issue mf-2536 and pr #7576.
Expand Down Expand Up @@ -121,10 +122,11 @@ export function TipButton(props: Props) {
})
}, [recipient, receiverUserId, accounts])

const location = useLocation()
useEffect(() => {
if (disabled || !info?.actionsElement?.realCurrent) return
info.actionsElement.realCurrent.style.flex = '1'
}, [disabled, info?.actionsElement?.realCurrent])
}, [disabled, info?.actionsElement?.realCurrent, location.pathname])

if (disabled) return null

Expand Down
8 changes: 6 additions & 2 deletions packages/shared/src/UI/components/PluginCardFrame/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface PluginCardFrameMiniProps {

export function PluginCardFrameMini({ icon, title, provider, providerLink, children }: PluginCardFrameMiniProps) {
const t = useSharedTrans()
const { classes } = useStyles()
const { classes, theme } = useStyles()

const PluginName = useMemo(() => {
return (
Expand Down Expand Up @@ -84,7 +84,11 @@ export function PluginCardFrameMini({ icon, title, provider, providerLink, child
</Stack>
</Stack>
<Stack flex={1} justifyContent="center" alignItems="center" p={1.5}>
{children ?? <LoadingStatus iconSize={24}>{t.plugin_card_frame_loading()}</LoadingStatus>}
{children ?? (
<LoadingStatus iconSize={24} color={theme.palette.maskColor.main}>
{t.plugin_card_frame_loading()}
</LoadingStatus>
)}
</Stack>
</Stack>
)
Expand Down

0 comments on commit 4c3bb2b

Please sign in to comment.