Pass interests update time in topics header

This commit is contained in:
Eric Bailey
2026-09-04 12:58:00 -05:00
parent 2189d4b869
commit 546c34b1cf
5 changed files with 62 additions and 15 deletions
+1 -1
View File
@@ -117,7 +117,7 @@
"@bsky.app/tapper": "^0.6.1",
"@bsky.app/video": "0.3.6",
"@bsky.app/video-compressor": "0.2.0",
"@bsky/sdk": "1.0.1",
"@bsky/sdk": "1.1.2",
"@emoji-mart/data": "^1.2.1",
"@emoji-mart/react": "^1.1.1",
"@expo/html-elements": "^0.12.5",
+5 -5
View File
@@ -297,8 +297,8 @@ importers:
specifier: 0.2.0
version: 0.2.0(expo@57.0.8)(react-native@0.86.0(patch_hash=dd549527bb84c88acc7b0b1d521c9f4b666fda484c75cd0b282f8e9838524909)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.0(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.0(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3)
'@bsky/sdk':
specifier: 1.0.1
version: 1.0.1(@atproto/lex@0.3.8)
specifier: 1.1.2
version: 1.1.2(@atproto/lex@0.3.8)
'@emoji-mart/data':
specifier: ^1.2.1
version: 1.2.1
@@ -1750,8 +1750,8 @@ packages:
react: '*'
react-native: '*'
'@bsky/sdk@1.0.1':
resolution: {integrity: sha512-COhrmIZFsUJ1gj4gvqm2UWkRhTbmXZAL1osTZKgSaFftD4Xy0RRl8S9SRluCxo4/VPw/R3p7NQZ4X3BQFbUjVQ==}
'@bsky/sdk@1.1.2':
resolution: {integrity: sha512-wMZXVdxnSHViyVrqm+eOpJLZAwfuWLX8gvuCEyV++4k/E/gp9inxQevzuNyCFZv/XJAZ4xRh1WXN7kymF4UMXA==}
engines: {node: '>=22.12.0'}
peerDependencies:
'@atproto/lex': ^0.3.0
@@ -10770,7 +10770,7 @@ snapshots:
react: 19.2.3
react-native: 0.86.0(patch_hash=dd549527bb84c88acc7b0b1d521c9f4b666fda484c75cd0b282f8e9838524909)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.0(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.0(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1)
'@bsky/sdk@1.0.1(@atproto/lex@0.3.8)':
'@bsky/sdk@1.1.2(@atproto/lex@0.3.8)':
dependencies:
'@atproto-labs/handle-resolver': 0.4.8
'@atproto/lex': 0.3.8
+50
View File
@@ -0,0 +1,50 @@
import {describe, expect, it, jest} from '@jest/globals'
import {type UsePreferencesQueryResponse} from '#/state/queries/preferences'
jest.mock('#/env', () => ({IS_WEB: false}))
import {aggregateUserInterests, createBskyTopicsHeader} from '../utils'
function preferences(
interests: Pick<
UsePreferencesQueryResponse['interests'],
'tags' | 'updatedAt'
>,
) {
return {interests} as UsePreferencesQueryResponse
}
describe('aggregateUserInterests', () => {
it('appends the update timestamp after a semicolon', () => {
expect(
createBskyTopicsHeader(
aggregateUserInterests(
preferences({
tags: ['animals', 'music'],
updatedAt: '2026-09-03T17:00:00.000Z',
}),
),
),
).toEqual({
'x-atproto-bsky-topics': 'animals,music;2026-09-03T17:00:00.000Z',
})
})
it('supports interests created before update timestamps were recorded', () => {
expect(aggregateUserInterests(preferences({tags: ['animals']}))).toBe(
'animals',
)
})
it('passes the timestamp when the user has no selected interests', () => {
expect(
aggregateUserInterests(
preferences({
tags: [],
updatedAt: '2026-09-03T17:00:00.000Z',
}),
),
).toBe(';2026-09-03T17:00:00.000Z')
})
})
+5 -1
View File
@@ -19,7 +19,11 @@ export function createBskyTopicsHeader(userInterests?: string) {
export function aggregateUserInterests(
preferences?: UsePreferencesQueryResponse,
) {
return preferences?.interests?.tags?.join(',') || ''
const tags = preferences?.interests.tags ?? []
const updatedAt = preferences?.interests.updatedAt
const interests = tags.join(',')
return updatedAt ? `${interests};${updatedAt}` : interests
}
export function isBlueskyOwnedFeed(feedUri: string) {
+1 -8
View File
@@ -112,14 +112,7 @@ function Inner({
try {
await pdsClient.call(setInterestsPref, {tags: interests})
qc.setQueriesData(
{queryKey: preferencesQueryKey},
(old?: UsePreferencesQueryResponse) => {
if (!old) return old
old.interests.tags = interests
return old
},
)
await qc.invalidateQueries({queryKey: preferencesQueryKey})
await Promise.all([
qc.resetQueries({queryKey: createSuggestedStarterPacksQueryKey()}),
qc.resetQueries({queryKey: createGetSuggestedFeedsQueryKey()}),