Skip to content

Commit

Permalink
fix: firefox does not connect correctly close jira-42 (#3413)
Browse files Browse the repository at this point in the history
* fix: firefox does not connect correctly close jira-42

* Update packages/maskbook/src/extension/background-script/EthereumServices/send.ts

Co-authored-by: guanbinrui <[email protected]>

Co-authored-by: guanbinrui <[email protected]>
  • Loading branch information
Jack-Works and guanbinrui committed Jun 20, 2021
1 parent d311dfe commit eff2fe4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Persona } from '../../../database'
import { definedSocialNetworkUIs, loadSocialNetworkUI } from '../../../social-network'
import { definedSocialNetworkUIs, loadSocialNetworkUI, loadSocialNetworkUISync } from '../../../social-network'

import ProviderLine, { ProviderLineProps } from './ProviderLine'
import { currentSetupGuideStatus } from '../../../settings/settings'
Expand All @@ -11,6 +11,7 @@ import { delay } from '../../../utils/utils'
import { SetupGuideStep } from '../../../components/InjectedComponents/SetupGuide'
import { Flags } from '../../../utils/flags'
import { requestSNSAdaptorPermission } from '../../../social-network/utils/permissions'
import { useEffect } from 'react'

interface ProfileBoxProps {
persona: Persona | null
Expand All @@ -35,8 +36,13 @@ export default function ProfileBox({ persona, ProviderLineProps }: ProfileBoxPro
.filter((x) => x)
const [detachProfile, , setDetachProfile] = useModal(DashboardPersonaUnlinkConfirmDialog)

useEffect(() => {
providers.forEach((provider) => loadSocialNetworkUI(provider.internalName))
}, [providers])

const onConnect = async (provider: typeof providers[0]) => {
const ui = await loadSocialNetworkUI(provider.internalName)
const ui = loadSocialNetworkUISync(provider.internalName)
if (!ui) throw new Error('This process must be sync')
// TODO: what if it does not have a (single?) home page? (e.g. mastdon)
// TODO: maybe add a new action "onConnect"?
const home = ui.utils.getHomePage?.()
Expand Down Expand Up @@ -65,7 +71,8 @@ export default function ProfileBox({ persona, ProviderLineProps }: ProfileBoxPro
key={index}
onAction={() => (provider.connected ? onDisconnect(provider) : onConnect(provider))}
{...provider}
{...ProviderLineProps}></ProviderLine>
{...ProviderLineProps}
/>
))}
{detachProfile}
</>
Expand Down
4 changes: 3 additions & 1 deletion packages/maskbook/src/plugins/Wallet/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,6 @@ export const currentGasNowSettings = createGlobalSettings<GasNow | null>(
(a: GasNow | null, b: GasNow | null) => isEqual(a, b),
)

connectGasNow()
try {
connectGasNow()
} catch {}
4 changes: 4 additions & 0 deletions packages/maskbook/src/social-network/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@ export async function loadSocialNetworkUI(identifier: string): Promise<SocialNet
}
return ui
}
export function loadSocialNetworkUISync(identifier: string): SocialNetworkUI.Definition | null {
if (definedSocialNetworkUIsResolved.has(identifier)) return definedSocialNetworkUIsResolved.get(identifier)!
return null
}

0 comments on commit eff2fe4

Please sign in to comment.