return a promise for getReferrerInfo
This commit is contained in:
@@ -8,6 +8,8 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
export 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
|
||||||
@@ -18,10 +20,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') {
|
||||||
return {
|
resolve({
|
||||||
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
|
||||||
@@ -29,6 +31,6 @@ export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
|||||||
console.error('Failed to parse referrer URL')
|
console.error('Failed to parse referrer URL')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
resolve(null)
|
||||||
return null
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user