Pass interests update time in topics header
This commit is contained in:
+1
-1
@@ -117,7 +117,7 @@
|
|||||||
"@bsky.app/tapper": "^0.6.1",
|
"@bsky.app/tapper": "^0.6.1",
|
||||||
"@bsky.app/video": "0.3.6",
|
"@bsky.app/video": "0.3.6",
|
||||||
"@bsky.app/video-compressor": "0.2.0",
|
"@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/data": "^1.2.1",
|
||||||
"@emoji-mart/react": "^1.1.1",
|
"@emoji-mart/react": "^1.1.1",
|
||||||
"@expo/html-elements": "^0.12.5",
|
"@expo/html-elements": "^0.12.5",
|
||||||
|
|||||||
Generated
+5
-5
@@ -297,8 +297,8 @@ importers:
|
|||||||
specifier: 0.2.0
|
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)
|
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':
|
'@bsky/sdk':
|
||||||
specifier: 1.0.1
|
specifier: 1.1.2
|
||||||
version: 1.0.1(@atproto/lex@0.3.8)
|
version: 1.1.2(@atproto/lex@0.3.8)
|
||||||
'@emoji-mart/data':
|
'@emoji-mart/data':
|
||||||
specifier: ^1.2.1
|
specifier: ^1.2.1
|
||||||
version: 1.2.1
|
version: 1.2.1
|
||||||
@@ -1750,8 +1750,8 @@ packages:
|
|||||||
react: '*'
|
react: '*'
|
||||||
react-native: '*'
|
react-native: '*'
|
||||||
|
|
||||||
'@bsky/sdk@1.0.1':
|
'@bsky/sdk@1.1.2':
|
||||||
resolution: {integrity: sha512-COhrmIZFsUJ1gj4gvqm2UWkRhTbmXZAL1osTZKgSaFftD4Xy0RRl8S9SRluCxo4/VPw/R3p7NQZ4X3BQFbUjVQ==}
|
resolution: {integrity: sha512-wMZXVdxnSHViyVrqm+eOpJLZAwfuWLX8gvuCEyV++4k/E/gp9inxQevzuNyCFZv/XJAZ4xRh1WXN7kymF4UMXA==}
|
||||||
engines: {node: '>=22.12.0'}
|
engines: {node: '>=22.12.0'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@atproto/lex': ^0.3.0
|
'@atproto/lex': ^0.3.0
|
||||||
@@ -10770,7 +10770,7 @@ snapshots:
|
|||||||
react: 19.2.3
|
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)
|
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:
|
dependencies:
|
||||||
'@atproto-labs/handle-resolver': 0.4.8
|
'@atproto-labs/handle-resolver': 0.4.8
|
||||||
'@atproto/lex': 0.3.8
|
'@atproto/lex': 0.3.8
|
||||||
|
|||||||
@@ -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')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -19,7 +19,11 @@ export function createBskyTopicsHeader(userInterests?: string) {
|
|||||||
export function aggregateUserInterests(
|
export function aggregateUserInterests(
|
||||||
preferences?: UsePreferencesQueryResponse,
|
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) {
|
export function isBlueskyOwnedFeed(feedUri: string) {
|
||||||
|
|||||||
@@ -112,14 +112,7 @@ function Inner({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await pdsClient.call(setInterestsPref, {tags: interests})
|
await pdsClient.call(setInterestsPref, {tags: interests})
|
||||||
qc.setQueriesData(
|
await qc.invalidateQueries({queryKey: preferencesQueryKey})
|
||||||
{queryKey: preferencesQueryKey},
|
|
||||||
(old?: UsePreferencesQueryResponse) => {
|
|
||||||
if (!old) return old
|
|
||||||
old.interests.tags = interests
|
|
||||||
return old
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
qc.resetQueries({queryKey: createSuggestedStarterPacksQueryKey()}),
|
qc.resetQueries({queryKey: createSuggestedStarterPacksQueryKey()}),
|
||||||
qc.resetQueries({queryKey: createGetSuggestedFeedsQueryKey()}),
|
qc.resetQueries({queryKey: createGetSuggestedFeedsQueryKey()}),
|
||||||
|
|||||||
Reference in New Issue
Block a user