Skip to content

Commit

Permalink
fix: flags (#11965)
Browse files Browse the repository at this point in the history
* fix: twitter handle

* refactor: flags

---------

Co-authored-by: Wukong Sun <[email protected]>
  • Loading branch information
guanbinrui and swkatmask committed Nov 29, 2024
1 parent d4854ab commit de93523
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
22 changes: 3 additions & 19 deletions packages/flags/src/flags/buildInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Environment, isEnvironment } from '@dimensiondev/holoflows-kit'
import { defer } from '@masknet/kit'

export interface BuildInfoFile {
Expand All @@ -11,30 +10,15 @@ export interface BuildInfoFile {
readonly REACT_DEVTOOLS_EDITOR_URL?: string
readonly channel: 'stable' | 'beta' | 'insider'
}

export async function getBuildInfo(): Promise<BuildInfoFile> {
try {
const hasBrowserAPI = isEnvironment(Environment.HasBrowserAPI)
const b = (globalThis as any).browser
const manifestVersion = hasBrowserAPI ? b.runtime.getManifest().version : undefined
const response = await fetch(hasBrowserAPI ? b.runtime.getURL('/build-info.json') : '/build-info.json')
const env: BuildInfoFile = await response.json()
if (manifestVersion) Object.assign(env, { VERSION: manifestVersion })
Object.freeze(env)
return env
} catch {
return {
channel: 'stable',
}
}
}
export let env: BuildInfoFile = {
channel: 'stable',
}
const [_promise, resolve] = defer<void>()
export const buildInfoReadyPromise = _promise
export async function setupBuildInfo(): Promise<void> {
return setupBuildInfoManually(await getBuildInfo())
return setupBuildInfoManually({
channel: 'stable',
})
}
export function setupBuildInfoManually(_env: BuildInfoFile) {
resolve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@ export function MentionLink({ platform, profileId, handle }: MentionLinkProps) {
const { data: twitterHandle, isLoading } = useQuery({
enabled: isTwitter && !handle,
queryKey: ['twitter-user-info', profileId],
queryFn: async () => {
return FireflyTwitter.getUserInfoById(profileId)
},
queryFn: () => FireflyTwitter.getUserInfoById(profileId),
select(data) {
return data?.username
},
})

const screenName = isTwitter ? twitterHandle || handle : handle
if (isLoading) return <LoadingBase size={12} />

if (!handle) return <span>the creator</span>
if (!screenName) return <span>the creator</span>

return (
<Link
href={resolveProfileUrl(
platform,
platform === FireflyRedPacketAPI.PlatformType.farcaster ? profileId : handle,
platform === FireflyRedPacketAPI.PlatformType.farcaster ? profileId : screenName,
)}
target="_blank"
className={classes.textLink}>
Expand Down

0 comments on commit de93523

Please sign in to comment.