Tells the Follow buttons what the signed-in user follows. FollowProvider
provides this context and useFollows reads it.
I
FollowContextValue
Provided by FollowProvider through FollowContext. The four
functions change the sets at once and undo the change when the request
fails. They resolve to whether it worked, and never reject.
- followPlaylist: (playlistId: string) => Promise<boolean>
- followUser: (userId: string) => Promise<boolean>
- followedPlaylistIds: Set<string>
- followedUserIds: Set<string>
-
isLoaded: boolean
False until the follows are fetched, and always for a visitor. The sets are empty until then, so a button would show "Follow" for a followed user. A failed fetch keeps it false, and is tried again 10 s later.
- unfollowPlaylist: (playlistId: string) => Promise<boolean>
- unfollowUser: (userId: string) => Promise<boolean>
v
defaultFollowValue: FollowContextValue
Given to a consumer outside FollowProvider, for which nothing is
followed.
v
FollowContext: React.Context<FollowContextValue>
Tells the Follow buttons what the signed-in user follows. Read it with
useFollows.
Usage
import * as mod from "src/contexts/social/FollowContext.ts";