Spaces:
Configuration error
Configuration error
Download frontend/src/hooks/use-migrate-user-consent.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/use-migrate-user-consent.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/hooks/use-migrate-user-consent.ts
-
curl -L -o use-migrate-user-consent.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/use-migrate-user-consent.ts
1.02 kB
| import React from "react"; | |
| import { handleCaptureConsent } from "#/utils/handle-capture-consent"; | |
| import { useSaveSettings } from "./mutation/use-save-settings"; | |
| export const useMigrateUserConsent = () => { | |
| const { mutate: saveUserSettings } = useSaveSettings(); | |
| /** | |
| * Migrate user consent to the settings store on the server. | |
| */ | |
| const migrateUserConsent = React.useCallback( | |
| async (args?: { handleAnalyticsWasPresentInLocalStorage: () => void }) => { | |
| const userAnalyticsConsent = localStorage.getItem("analytics-consent"); | |
| if (userAnalyticsConsent) { | |
| args?.handleAnalyticsWasPresentInLocalStorage(); | |
| await saveUserSettings( | |
| { user_consents_to_analytics: userAnalyticsConsent === "true" }, | |
| { | |
| onSuccess: () => { | |
| handleCaptureConsent(userAnalyticsConsent === "true"); | |
| }, | |
| }, | |
| ); | |
| localStorage.removeItem("analytics-consent"); | |
| } | |
| }, | |
| [], | |
| ); | |
| return { migrateUserConsent }; | |
| }; | |