Skip to content

Commit

Permalink
fix: mf-5088 get connected status (#10525)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill committed Aug 21, 2023
1 parent c3232c8 commit f435e05
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { getSiteType } from '@masknet/shared-base'
import { useQuery } from '@tanstack/react-query'
import Services from '../../../../service.js'

/**
* Get source page from hash
*/
const getSourceUrl = () => {
const search = location.hash.slice(location.hash.indexOf('?'))
return new URLSearchParams(search).get('source') ?? ''
}
import { useSearchParams } from 'react-router-dom'

export function useConnected() {
return useQuery(['connected-status'], async () => {
const [params] = useSearchParams()
const source = params.get('source') ?? ''
return useQuery(['connected-status', source], async () => {
const result = await Services.Helper.queryCurrentActiveTab()
if (!result) return
const url = result.url || getSourceUrl()
const url = result.url || source
const siteType = getSiteType(url)

if (!siteType) return { connected: false, url }
Expand Down

0 comments on commit f435e05

Please sign in to comment.