diff --git a/src/geolocation/util.ts b/src/geolocation/util.ts index e9250b0b4c..74311e7b90 100644 --- a/src/geolocation/util.ts +++ b/src/geolocation/util.ts @@ -3,6 +3,7 @@ import {type LocationGeocodedAddress} from 'expo-location' import {IS_ANDROID} from '#/env' import {logger} from '#/geolocation/logger' import {type Geolocation} from '#/geolocation/types' +import {device} from '#/storage' /** * Maps full US region names to their short codes. @@ -125,3 +126,21 @@ export function mergeGeolocations( }) return geolocation } + +/** + * Get's the merged geolocation as a string in the format of + * "countryCode-regionCode", or just "countryCode" if regionCode is not + * available. + */ +export function getGeolocationString() { + const geo = device.get(['mergedGeolocation']) + if (!geo) return + const {countryCode, regionCode} = geo + if (countryCode) { + if (regionCode) { + return `${countryCode}-${regionCode}` + } else { + return countryCode + } + } +} diff --git a/src/lib/api/feed/custom.ts b/src/lib/api/feed/custom.ts index 18bb8c8f07..540325fc5b 100644 --- a/src/lib/api/feed/custom.ts +++ b/src/lib/api/feed/custom.ts @@ -9,6 +9,7 @@ import { getAppLanguageAsContentLanguage, getContentLanguages, } from '#/state/preferences/languages' +import {getDeviceId} from '#/analytics/identifiers' import {type FeedAPI, type FeedAPIResponse} from './types' import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils' @@ -62,12 +63,15 @@ export class CustomFeedAPI implements FeedAPI { limit, }, { - headers: { - ...(isBlueskyOwned - ? createBskyTopicsHeader(this.userInterests) - : {}), - 'Accept-Language': contentLangs, - }, + headers: isBlueskyOwned + ? { + ...createBskyTopicsHeader(this.userInterests), + 'X-Bsky-Stable-Id': getDeviceId(), + 'Accept-Language': contentLangs, + } + : { + 'Accept-Language': contentLangs, + }, }, ) : await loggedOutFetch({...this.params, cursor, limit})