Skip to content

Commit 92bdaec

Browse files
committed
fixup! feat(firefly): add firefly session bind and restore with farcaster integration
1 parent 10ba83a commit 92bdaec

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

packages/mask/background/database/persona/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export interface PersonaRecord {
139139
createdAt: Date
140140
updatedAt: Date
141141
hasLogout?: boolean
142+
fireflyToken?: string
142143
/**
143144
* create a dummy persona which should hide to the user until
144145
* connected at least one website

packages/mask/content-script/components/InjectedComponents/SetupGuide/AccountConnectStatus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Trans } from '@lingui/react/macro'
12
import { Icons } from '@masknet/icons'
23
import { BindingDialog, LoadingStatus, SOCIAL_MEDIA_ROUND_ICON_MAPPING, type BindingDialogProps } from '@masknet/shared'
34
import { Sniffings, SOCIAL_MEDIA_NAME } from '@masknet/shared-base'
@@ -6,7 +7,6 @@ import { Box, Button, Typography } from '@mui/material'
67
import { memo } from 'react'
78
import { activatedSiteAdaptorUI } from '../../../site-adaptor-infra/ui.js'
89
import { SetupGuideContext } from './SetupGuideContext.js'
9-
import { Trans } from '@lingui/react/macro'
1010

1111
const useStyles = makeStyles()((theme) => {
1212
return {

packages/mask/popups/modals/ConnectSocialAccountModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { EMPTY_LIST, EnhanceableSite, PopupRoutes } from '@masknet/shared-base'
55
import { Telemetry } from '@masknet/web3-telemetry'
66
import { EventType } from '@masknet/web3-telemetry/types'
77
import { memo, useCallback } from 'react'
8+
import { useNavigate } from 'react-router-dom'
89
import { requestPermissionFromExtensionPage } from '../../../shared-ui/index.js'
910
import { EventMap } from '../../../shared/definitions/event.js'
1011
import { ConnectSocialAccounts } from '../../components/ConnectSocialAccounts/index.js'
1112
import { ActionModal, type ActionModalBaseProps } from '../../components/index.js'
1213
import { useSupportSocialNetworks } from '../../hooks/index.js'
13-
import { useNavigate } from 'react-router-dom'
1414

1515
export const ConnectSocialAccountModal = memo<ActionModalBaseProps>(function ConnectSocialAccountModal(props) {
1616
const { data: definedSocialNetworks = EMPTY_LIST } = useSupportSocialNetworks()

packages/mask/popups/pages/Personas/ConnectFirefly/index.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
PopupRoutes,
99
TimeoutError,
1010
} from '@masknet/shared-base'
11-
import { makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
11+
import { LoadingBase, makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
1212
import { addAccount, type AccountOptions, type FireflyAccount } from '@masknet/web3-providers'
1313
import { Social } from '@masknet/web3-providers/types'
1414
import { Box } from '@mui/material'
@@ -17,20 +17,29 @@ import { QRCode } from 'react-qrcode-logo'
1717
import { useNavigate } from 'react-router-dom'
1818
import urlcat from 'urlcat'
1919
import { useTitle } from '../../../hooks/index.js'
20-
import { useMount } from 'react-use'
20+
import { useAsyncFn, useMount } from 'react-use'
2121
import { createAccountByRelayService } from './createAccountByRelayService.js'
2222

2323
const useStyles = makeStyles()({
2424
container: {
2525
display: 'flex',
2626
justifyContent: 'center',
2727
alignItems: 'center',
28+
position: 'relative',
29+
},
30+
loading: {
31+
backgroundColor: 'rgba(255,255,255,0.5)',
32+
position: 'absolute',
33+
inset: 0,
34+
display: 'flex',
35+
justifyContent: 'center',
36+
alignItems: 'center',
2837
},
2938
})
3039

3140
function useLogin() {
3241
const { showSnackbar } = usePopupCustomSnackbar()
33-
return useCallback(
42+
return useAsyncFn(
3443
async function login(createAccount: () => Promise<FireflyAccount>, options?: Omit<AccountOptions, 'source'>) {
3544
try {
3645
const account = await createAccount()
@@ -76,14 +85,15 @@ export const Component = memo(function ConnectFireflyPage() {
7685
const [url, setUrl] = useState('')
7786

7887
const navigate = useNavigate()
79-
const login = useLogin()
88+
const [{ loading }, login] = useLogin()
8089

8190
useMount(async () => {
8291
login(async () => {
8392
try {
8493
const account = await createAccountByRelayService((url) => {
8594
setUrl(url)
8695
})
96+
console.log('account', account)
8797
return account
8898
} catch (err) {
8999
console.log('error', err)
@@ -103,6 +113,11 @@ export const Component = memo(function ConnectFireflyPage() {
103113
return (
104114
<Box className={classes.container}>
105115
<QRCode value={url} ecLevel="L" size={220} quietZone={16} eyeRadius={100} qrStyle="dots" />
116+
{loading ?
117+
<div className={classes.loading}>
118+
<LoadingBase size={30} />
119+
</div>
120+
: null}
106121
</Box>
107122
)
108123
})

0 commit comments

Comments
 (0)