Skip to content

Commit

Permalink
fix: mf-5262 dsearch missing worker (#10780)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill committed Sep 18, 2023
1 parent 3f4aeae commit ed5fef8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/plugins/Trader/src/SiteAdaptor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const site: Plugin.SiteAdaptor.Definition = {
SearchResultInspector: {
ID: PluginID.Trader,
UI: {
Content({ currentResult, resultList, isProfilePage, identity }) {
Content: function TraderSearchResultContent({ currentResult, resultList, isProfilePage, identity }) {
if (!resultList.length || !currentResult) return null
const { chainId, keyword, pluginID } = currentResult
return (
Expand Down
9 changes: 9 additions & 0 deletions packages/plugins/Trader/src/Worker/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Plugin } from '@masknet/plugin-infra'
import { base } from '../base.js'
import '../messages.js'

const worker: Plugin.Worker.Definition = {
...base,
init(signal) {},
}
export default worker
4 changes: 4 additions & 0 deletions packages/plugins/Trader/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ registerPlugin({
hotModuleReload: (hot) =>
import.meta.webpackHot?.accept('./Dashboard', () => hot(import('./Dashboard/index.js'))),
},
Worker: {
load: () => import('./Worker/index.js'),
hotModuleReload: (hot) => import.meta.webpackHot?.accept('./Worker', () => hot(import('./Worker/index.js'))),
},
})
23 changes: 13 additions & 10 deletions packages/plugins/Trader/src/trending/useTrending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { TrendingAPI } from '@masknet/web3-providers/types'
import { TokenType, type NonFungibleTokenActivity } from '@masknet/web3-shared-base'
import type { ChainId } from '@masknet/web3-shared-evm'
import { PluginTraderRPC } from '../messages.js'
import { useQuery } from '@tanstack/react-query'

export function useNFT_TrendingOverview(
pluginID: NetworkPluginID,
Expand Down Expand Up @@ -71,19 +72,22 @@ export function useTrendingById(
const currency = trending.getCurrency(result.chainId, result.source)

const {
value: coinTrending,
loading,
isLoading,
data: coinTrending,
error,
} = useAsync(async () => {
if (!currency || !result.source) return null
return PluginTraderRPC.getCoinTrending(result, currency)
}, [chainId, JSON.stringify(result), currency?.id])
} = useQuery({
queryKey: ['get-coin-trending', result, currency?.id],
queryFn: async () => {
if (!currency || !result.source) return null
return PluginTraderRPC.getCoinTrending(result, currency)
},
})

const { data: detailedToken } = useFungibleToken(result.pluginID, coinTrending?.coin.contract_address, undefined, {
chainId: coinTrending?.coin.chainId as ChainId,
})

if (loading) {
if (isLoading) {
return {
loading: true,
}
Expand All @@ -92,7 +96,7 @@ export function useTrendingById(
if (error) {
return {
loading: false,
error,
error: error as Error,
}
}

Expand All @@ -116,8 +120,7 @@ export function useTrendingById(
}
: null,
},
loading,
error,
loading: isLoading,
}
}

Expand Down

0 comments on commit ed5fef8

Please sign in to comment.