handle following and pinning feeds, acocunt createdAt

This commit is contained in:
Hailey
2024-06-10 00:41:03 -07:00
parent d2bdcc4c99
commit 6f188b0eb2
8 changed files with 98 additions and 43 deletions
+7 -2
View File
@@ -88,7 +88,12 @@ export const schema = z.object({
disableHaptics: z.boolean().optional(),
disableAutoplay: z.boolean().optional(),
kawaii: z.boolean().optional(),
starterPackId: z.string().optional(),
usedStarterPack: z
.object({
uri: z.string(),
cid: z.string(),
})
.optional(),
})
export type Schema = z.infer<typeof schema>
@@ -127,5 +132,5 @@ export const defaults: Schema = {
disableHaptics: false,
disableAutoplay: prefersReducedMotion,
kawaii: false,
starterPackId: undefined,
usedStarterPack: undefined,
}
+9 -9
View File
@@ -2,23 +2,23 @@ import React from 'react'
import * as persisted from '#/state/persisted'
type StateContext = string | undefined
type SetContext = (v: string) => void
type StateContext = {uri: string; cid: string} | undefined
type SetContext = (v: StateContext) => void
const stateContext = React.createContext<StateContext>(undefined)
const setContext = React.createContext<SetContext>((_: string) => {})
const setContext = React.createContext<SetContext>((_: StateContext) => {})
export function Provider({children}: {children: React.ReactNode}) {
const [state, setState] = React.useState<string>()
const [state, setState] = React.useState<StateContext>()
const setStateWrapped = (v: string) => {
const setStateWrapped = (v: StateContext) => {
setState(v)
persisted.write('starterPackId', v)
persisted.write('usedStarterPack', v)
}
React.useEffect(() => {
return persisted.onUpdate(() => {
setState(persisted.get('starterPackId'))
setState(persisted.get('usedStarterPack'))
})
}, [])
@@ -31,5 +31,5 @@ export function Provider({children}: {children: React.ReactNode}) {
)
}
export const useStarterPack = () => React.useContext(stateContext)
export const useSetStarterPack = () => React.useContext(setContext)
export const useUsedStarterPack = () => React.useContext(stateContext)
export const useSetUsedStarterPack = () => React.useContext(setContext)
+1 -1
View File
@@ -173,7 +173,7 @@ export function useFeedSourceInfoQuery({uri}: {uri: string}) {
export const useGetPopularFeedsQueryKey = ['getPopularFeeds']
export function useGetPopularFeedsQuery({limit = 10}: {limit?: number}) {
export function useGetPopularFeedsQuery(limit: number = 10) {
const agent = useAgent()
return useInfiniteQuery<
AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema,