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

Function onMutateAdvancedSettings

packages/shared/src/hooks/useMutateFilters.ts:123–145  ·  view source on GitHub ↗
(
  advancedSettings: FeedAdvancedSettings[],
  queryClient: QueryClient,
  manipulate: ManipulateAdvancedSettingsFunc,
  user: LoggedUser | undefined,
  feedId: string | undefined,
)

Source from the content-addressed store, hash-verified

121) => FeedSettings;
122
123const onMutateAdvancedSettings = async (
124 advancedSettings: FeedAdvancedSettings[],
125 queryClient: QueryClient,
126 manipulate: ManipulateAdvancedSettingsFunc,
127 user: LoggedUser | undefined,
128 feedId: string | undefined,
129): Promise<() => Promise<void>> => {
130 const queryKey = getFeedSettingsQueryKey(user, feedId);
131 const currentSettings = getCachedFeedSettingsOrThrow(
132 queryClient,
133 queryKey,
134 'advanced_settings',
135 );
136 const newData = manipulate(
137 normalizeFeedSettings(currentSettings),
138 advancedSettings,
139 );
140 const keys = [queryKey, queryKey];
141 await updateQueryData(queryClient, newData, keys);
142 return async () => {
143 await updateQueryData(queryClient, currentSettings, keys);
144 };
145};
146
147type ManipulateTagFunc = (
148 feedSettings: FeedSettings,

Callers 1

useMutateFiltersFunction · 0.85

Calls 4

getFeedSettingsQueryKeyFunction · 0.90
normalizeFeedSettingsFunction · 0.85
updateQueryDataFunction · 0.70

Tested by

no test coverage detected