This commit is contained in:
Hailey
2024-07-11 19:47:54 -07:00
parent eb53b61136
commit 1c1d45ba5a
@@ -7,9 +7,7 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
throw new NotImplementedError() throw new NotImplementedError()
} }
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> { export async function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
// Returning a promise to match the functionality on native
return new Promise(resolve => {
if ( if (
Platform.OS === 'web' && Platform.OS === 'web' &&
// for ssr // for ssr
@@ -20,10 +18,10 @@ export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
try { try {
const url = new URL(document.referrer) const url = new URL(document.referrer)
if (url.hostname !== 'bsky.app') { if (url.hostname !== 'bsky.app') {
resolve({ return {
referrer: url.href, referrer: url.href,
hostname: url.hostname, hostname: url.hostname,
}) }
} }
} catch { } catch {
// If something happens to the URL parsing, we don't want to actually cause any problems for the user. Just // If something happens to the URL parsing, we don't want to actually cause any problems for the user. Just
@@ -31,6 +29,5 @@ export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
console.error('Failed to parse referrer URL') console.error('Failed to parse referrer URL')
} }
} }
resolve(null) return null
})
} }