diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/hooks/useCreateSupportLink.ts | 39 | ||||
-rw-r--r-- | src/lib/notifications/notifications.ts | 3 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/hooks/useCreateSupportLink.ts b/src/lib/hooks/useCreateSupportLink.ts new file mode 100644 index 000000000..5ec7578c5 --- /dev/null +++ b/src/lib/hooks/useCreateSupportLink.ts @@ -0,0 +1,39 @@ +import {useCallback} from 'react' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {useSession} from '#/state/session' + +export const ZENDESK_SUPPORT_URL = + 'https://blueskyweb.zendesk.com/hc/requests/new' + +export enum SupportCode { + AA_DID = 'AA_DID', +} + +/** + * {@link https://support.zendesk.com/hc/en-us/articles/4408839114522-Creating-pre-filled-ticket-forms} + */ +export function useCreateSupportLink() { + const {_} = useLingui() + const {currentAccount} = useSession() + + return useCallback( + ({code, email}: {code: SupportCode; email?: string}) => { + const url = new URL(ZENDESK_SUPPORT_URL) + if (currentAccount) { + url.search = new URLSearchParams({ + tf_anonymous_requester_email: email || currentAccount.email || '', // email will be defined + tf_description: + `[Code: ${code}] — ` + _(msg`Please write your message below:`), + /** + * Custom field specific to {@link ZENDESK_SUPPORT_URL} form + */ + tf_17205412673421: currentAccount.handle + ` (${currentAccount.did})`, + }).toString() + } + return url.toString() + }, + [_, currentAccount], + ) +} diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index 0d2f9ed09..67a38a52c 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -192,6 +192,9 @@ export function useNotificationsRegistration() { * Register the push token with the Bluesky server, whenever it changes. * This is also fired any time `getDevicePushTokenAsync` is called. * + * Since this is registered immediately after `getAndRegisterPushToken`, it + * should also detect that getter and be fired almost immediately after this. + * * According to the Expo docs, there is a chance that the token will change * while the app is open in some rare cases. This will fire * `registerPushToken` whenever that happens. |