-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eric/preferences #1873
Eric/preferences #1873
Conversation
src/lib/labeling/const.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stuff was only used by preferences, so I co-located it
src/state/models/ui/preferences.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining items here will be removed as we update the things that rely on them
src/state/models/ui/saved-feeds.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be removed after we replace our My Feeds page stuff
const feedSourceNSIDs = { | ||
feed: 'app.bsky.feed.generator', | ||
list: 'app.bsky.graph.list', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a clear source for these yet?
queryKey: usePreferencesQueryKey, | ||
queryFn: async () => { | ||
const res = await agent.getPreferences() | ||
const preferences: UsePreferencesQueryResponse = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've set defaults for all (or most at least) values here, and updated types to match
// triggers a refetch | ||
await queryClient.invalidateQueries({ | ||
queryKey: usePreferencesQueryKey, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rn I'm refetching on every mutation, I figured a shadow cache was overkill for these mutations. We could use RQ cache too.
export const ILLEGAL_LABEL_GROUP: LabelGroupConfig = { | ||
id: 'illegal', | ||
title: 'Illegal Content', | ||
warning: 'Illegal Content', | ||
values: ['csam', 'dmca-violation', 'nudity-nonconsensual'], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These and the other three are unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah don't worry about that, there's a cleanup pass that needs to happen on the labeling layer to get everything 100%
}, | ||
} | ||
|
||
export function getModerationOpts({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacement for rootStore.preferences.moderationOpts
, but isn't used anywhere yet
export type UsePreferencesQueryResponse = Omit< | ||
BskyPreferences, | ||
'contentLabels' | 'feedViewPrefs' | 'feeds' | ||
> & { | ||
/* | ||
* Content labels previously included 'show', which has been deprecated in | ||
* favor of 'ignore'. The API can return legacy data from the database, and | ||
* we clean up the data in `usePreferencesQuery`. | ||
*/ | ||
contentLabels: Record<ConfigurableLabelGroup, LabelPreference> | ||
feedViewPrefs: BskyPreferences['feedViewPrefs']['home'] | ||
/** | ||
* User thread-view prefs, including newer fields that may not be typed yet. | ||
*/ | ||
threadViewPrefs: ThreadViewPreferences | ||
userAge: number | undefined | ||
feeds: Required<BskyPreferences['feeds']> & { | ||
unpinned: string[] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up some types here to include the labs values and computed values done in the hook
/** | ||
* Content labels previously included 'show', which has been deprecated in | ||
* favor of 'ignore'. The API can return legacy data from the database, and | ||
* we clean up the data in `usePreferencesQuery`. | ||
* | ||
* @deprecated | ||
*/ | ||
export function temp__migrateLabelPref( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made this even more obvious
setBirthDate({birthDate: model.birthDate}) | ||
|
||
if (IS_PROD(model.serviceUrl)) { | ||
setSavedFeeds(DEFAULT_PROD_FEEDS) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side effects, including setting default saved feeds
} from '#/state/queries/preferences' | ||
import {useFeedSourceInfoQuery} from '#/state/queries/feed' | ||
|
||
export const NewFeedSourceCard = observer(function FeedSourceCardImpl({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't want to migrate all usages yet, so built this alongside the old one for now
const [value, setValue] = useState(initialValue) | ||
const {mutate: setFeedViewPref} = useSetFeedViewPreferencesMutation() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little jumpy as the API requests succeeds and state updates, need to come back here later
variables?.hideQuotePosts ?? | ||
preferences?.feedViewPrefs?.hideQuotePosts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local optimistic updates here
const {isPending: isPinPending, mutateAsync: pinFeed} = usePinFeedMutation() | ||
const {isPending: isUnpinPending, mutateAsync: unpinFeed} = | ||
useUnpinFeedMutation() | ||
const {isPending: isMovePending, mutateAsync: setSavedFeeds} = | ||
useSetSaveFeedsMutation() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No optimistic updates here bc I don't have a shared context to use variables
and I didn't want to complicate things with the query cache. We can migrate to that if we need to, but for now this works well. Pending states disable buttons while async req is pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, merge whenevs
No description provided.