Skip to content

Commit

Permalink
feat(native-app): log confirm actions of subpoena to backend (#16862)
Browse files Browse the repository at this point in the history
* feat: log confirm actions of subpoena to backend

* fix: better comment

* fix: confirm action can not be null

* feat: make sure to await actions

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
thoreyjona and kodiakhq[bot] authored Nov 15, 2024
1 parent 8e051c5 commit a6fa992
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
7 changes: 7 additions & 0 deletions apps/native/app/src/graphql/queries/inbox.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ mutation PostMailActionMutation($input: DocumentsV2MailActionInput!) {
success
}
}

query DocumentConfirmActions($input: DocumentConfirmActionsInput!) {
documentV2ConfirmActions(input: $input) {
id
confirmed
}
}
22 changes: 20 additions & 2 deletions apps/native/app/src/screens/document-detail/document-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
},
},
])
}
Expand Down

0 comments on commit a6fa992

Please sign in to comment.