mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Allow marking recent emails as library items
This commit is contained in:
parent
69388148aa
commit
b872c33ba9
3 changed files with 47 additions and 2 deletions
|
|
@ -0,0 +1,35 @@
|
|||
import { gqlFetcher } from '../networkHelpers'
|
||||
|
||||
type MarkEmailAsItemDataResponseData = {
|
||||
markEmailAsItem?: MarkEmailAsItemData
|
||||
}
|
||||
|
||||
type MarkEmailAsItemData = {
|
||||
success: Boolean
|
||||
errorCodes?: unknown[]
|
||||
}
|
||||
|
||||
export async function markEmailAsItemMutation(
|
||||
recentEmailId: String
|
||||
): Promise<void> {
|
||||
const mutation = `
|
||||
mutation MarkRecentEmailAsItem($recentEmailId: ID!) {
|
||||
markEmailAsItem(recentEmailId:$recentEmailId) {
|
||||
... on MarkEmailAsItemError {
|
||||
errorCodes
|
||||
}
|
||||
... on MarkEmailAsItemSuccess {
|
||||
success
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
const data = await gqlFetcher(mutation, { recentEmailId })
|
||||
console.log('recentEmailId: ', data)
|
||||
const output = data as MarkEmailAsItemDataResponseData | undefined
|
||||
const error = output?.markEmailAsItem?.errorCodes?.find(() => true)
|
||||
console.log('error: ', error)
|
||||
if (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
|
@ -118,7 +118,6 @@ export default function EmailsPage(): JSX.Element {
|
|||
<>
|
||||
<SettingsTable
|
||||
pageId="settings-emails-tag"
|
||||
pageHeadline="Email Addresses"
|
||||
pageInfoLink="/help/newsletters"
|
||||
headerTitle="Address"
|
||||
createTitle="Create a new email address"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import {
|
|||
} from '../../../components/elements/ModalPrimitives'
|
||||
import TextArea from 'antd/lib/input/TextArea'
|
||||
import { StyledTextArea } from '../../../components/elements/StyledTextArea'
|
||||
import { markEmailAsItemMutation } from '../../../lib/networking/mutations/markEmailAsItemMutation'
|
||||
import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers'
|
||||
|
||||
type TypeChipProps = {
|
||||
type: string
|
||||
|
|
@ -202,8 +204,17 @@ export default function RecentEmails(): JSX.Element {
|
|||
/>
|
||||
<MoreOptionItem
|
||||
text="Mark as article"
|
||||
action={() => {
|
||||
action={async () => {
|
||||
console.log('marking as email', recentEmail)
|
||||
showSuccessToast('Marking email as article')
|
||||
try {
|
||||
await markEmailAsItemMutation(recentEmail.id)
|
||||
} catch (err) {
|
||||
console.log('error marking as article: ', err)
|
||||
showErrorToast('Error marking item as article')
|
||||
return
|
||||
}
|
||||
showSuccessToast('Email added to library')
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
Loading…
Reference in a new issue