MCPcopy Create free account
hub / github.com/dailydotdev/apps / useTagAndSource

Function useTagAndSource

packages/shared/src/hooks/useTagAndSource.ts:48–419  ·  view source on GitHub ↗
({
  origin,
  postId,
  shouldInvalidateQueries = true,
  shouldUpdateAlerts = true,
  feedId,
  shouldFilterLocally = false,
}: UseTagAndSourceProps)

Source from the content-addressed store, hash-verified

46}
47
48export default function useTagAndSource({
49 origin,
50 postId,
51 shouldInvalidateQueries = true,
52 shouldUpdateAlerts = true,
53 feedId,
54 shouldFilterLocally = false,
55}: UseTagAndSourceProps): UseTagAndSource {
56 const queryClient = useQueryClient();
57 const { alerts, updateAlerts } = useContext(AlertContext);
58 const { user, showLogin } = useContext(AuthContext);
59 const { logEvent } = useLogContext();
60 const shouldShowLogin = useCallback(
61 (requireLogin?: boolean) => (user ? false : requireLogin),
62 [user],
63 );
64
65 const {
66 followTags,
67 unfollowTags,
68 blockTag,
69 unblockTag,
70 unblockSource,
71 blockSource,
72 followSource,
73 unfollowSource,
74 } = useMutateFilters(user, feedId, shouldFilterLocally);
75
76 const [invalidateQueries] = useDebounceFn(() => {
77 if (!shouldInvalidateQueries) {
78 return;
79 }
80
81 queryClient.invalidateQueries({
82 queryKey: generateQueryKey(SharedFeedPage.MyFeed, user),
83 });
84 }, 100);
85
86 const invalidateContentPreferences = useCallback(
87 ({
88 entity,
89 subQuery,
90 }: {
91 entity: ContentPreferenceType;
92 subQuery: RequestKey;
93 }) => {
94 queryClient.invalidateQueries({
95 queryKey: generateQueryKey(
96 RequestKey.ContentPreference,
97 user,
98 subQuery,
99 {
100 feedId: feedId || user?.id,
101 entity,
102 },
103 ),
104 });
105 },

Callers 14

PersonaSelectorFunction · 0.85
FeedSettingsTagsSectionFunction · 0.85
TagsDirectoryPageFunction · 0.85
TagTopicPageFunction · 0.85
TagSelectionFunction · 0.85
PersonaQuizPhasesFunction · 0.85
PostOptionButtonContentFunction · 0.85
useSourceActionsBlockFunction · 0.85
useSourceActionsFollowFunction · 0.85
useAdvancedSettingsFunction · 0.85
useFollowPostTagsFunction · 0.85
useBlockPostPanelFunction · 0.85

Calls 5

useLogContextFunction · 0.90
generateQueryKeyFunction · 0.90
useMutateFiltersFunction · 0.85
useDebounceFnFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected