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

Function onMutateSourcesSettings

packages/shared/src/hooks/useMutateFilters.ts:178–197  ·  view source on GitHub ↗
(
  source: Source,
  queryClient: QueryClient,
  manipulate: ManipulateSourceFunc,
  user: LoggedUser | undefined,
  feedId: string | undefined,
)

Source from the content-addressed store, hash-verified

176) => FeedSettings;
177
178const onMutateSourcesSettings = async (
179 source: Source,
180 queryClient: QueryClient,
181 manipulate: ManipulateSourceFunc,
182 user: LoggedUser | undefined,
183 feedId: string | undefined,
184): Promise<() => Promise<void>> => {
185 const queryKey = getFeedSettingsQueryKey(user, feedId);
186 const currentSettings = getCachedFeedSettingsOrThrow(
187 queryClient,
188 queryKey,
189 'sources',
190 );
191 const newData = manipulate(normalizeFeedSettings(currentSettings), source);
192 const keys = [queryKey, getFeedSettingsQueryKey(user, feedId)];
193 await updateQueryData(queryClient, newData, keys);
194 return async () => {
195 await updateQueryData(queryClient, currentSettings, keys);
196 };
197};
198
199const clearNotificationPreference = async ({
200 queryClient,

Callers 1

useMutateFiltersFunction · 0.85

Calls 4

getFeedSettingsQueryKeyFunction · 0.90
normalizeFeedSettingsFunction · 0.85
updateQueryDataFunction · 0.70

Tested by

no test coverage detected