Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: firefox does not connect correctly close jira-42 #3413

Merged
merged 2 commits into from
Jun 20, 2021
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
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 {}
Jack-Works marked this conversation as resolved.
Show resolved Hide resolved
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
}