diff --git a/apps/native/app/src/graphql/queries/inbox.graphql b/apps/native/app/src/graphql/queries/inbox.graphql index 73209b4263fc..ff129a3e424a 100644 --- a/apps/native/app/src/graphql/queries/inbox.graphql +++ b/apps/native/app/src/graphql/queries/inbox.graphql @@ -48,3 +48,10 @@ mutation PostMailActionMutation($input: DocumentsV2MailActionInput!) { success } } + +query DocumentConfirmActions($input: DocumentConfirmActionsInput!) { + documentV2ConfirmActions(input: $input) { + id + confirmed + } +} diff --git a/apps/native/app/src/screens/document-detail/document-detail.tsx b/apps/native/app/src/screens/document-detail/document-detail.tsx index e70d6f884bfc..9914b0937f78 100644 --- a/apps/native/app/src/screens/document-detail/document-detail.tsx +++ b/apps/native/app/src/screens/document-detail/document-detail.tsx @@ -27,6 +27,7 @@ import { DocumentV2Action, ListDocumentFragmentDoc, useGetDocumentQuery, + useDocumentConfirmActionsLazyQuery, } from '../../graphql/types/schema' import { createNavigationOptionHooks } from '../../hooks/create-navigation-option-hooks' import { useConnectivityIndicator } from '../../hooks/use-connectivity-indicator' @@ -248,6 +249,17 @@ export const DocumentDetailScreen: NavigationFunctionComponent<{ const [pdfUrl, setPdfUrl] = useState('') const [refetching, setRefetching] = useState(false) + const [logConfirmedAction] = useDocumentConfirmActionsLazyQuery({ + fetchPolicy: 'no-cache', + }) + + const confirmAction = async (confirmed: boolean) => { + // Adding a suffix '_app' to the id since the backend is currently not distinguishing between the app and the web + await logConfirmedAction({ + variables: { input: { id: `${docId}_app`, confirmed: confirmed } }, + }) + } + const refetchDocumentContent = async () => { setRefetching(true) try { @@ -268,11 +280,17 @@ export const DocumentDetailScreen: NavigationFunctionComponent<{ { text: intl.formatMessage({ id: 'inbox.markAllAsReadPromptCancel' }), style: 'cancel', - onPress: () => Navigation.pop(componentId), + onPress: async () => { + await confirmAction(false) + Navigation.pop(componentId) + }, }, { text: intl.formatMessage({ id: 'inbox.openDocument' }), - onPress: refetchDocumentContent, + onPress: async () => { + await confirmAction(true) + await refetchDocumentContent() + }, }, ]) }