mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add remove pocket integration to web
This commit is contained in:
parent
950d41a387
commit
ab1154ef6f
2 changed files with 11 additions and 4 deletions
|
|
@ -35,6 +35,7 @@ export function useGetIntegrationsQuery(): IntegrationsQueryResponse {
|
|||
... on IntegrationsSuccess {
|
||||
integrations {
|
||||
id
|
||||
name
|
||||
type
|
||||
token
|
||||
enabled
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ export default function Integrations(): JSX.Element {
|
|||
const readwiseConnected = useMemo(() => {
|
||||
return integrations.find((i) => i.name == 'READWISE' && i.type == 'EXPORT')
|
||||
}, [integrations])
|
||||
const isConnected = (name: string, type: string) => {
|
||||
return integrations.find((i) => i.name === name && i.type === type)
|
||||
}
|
||||
|
||||
const deleteIntegration = async (id: string) => {
|
||||
try {
|
||||
|
|
@ -121,6 +124,7 @@ export default function Integrations(): JSX.Element {
|
|||
}, [router])
|
||||
|
||||
useEffect(() => {
|
||||
const pocketConnected = isConnected('POCKET', 'IMPORT')
|
||||
setIntegrationsArray([
|
||||
{
|
||||
icon: '/static/icons/logseq.svg',
|
||||
|
|
@ -168,16 +172,18 @@ export default function Integrations(): JSX.Element {
|
|||
title: 'Pocket',
|
||||
subText: 'Pocket is a place to save articles, videos, and more.',
|
||||
button: {
|
||||
text: 'Connect to Pocket',
|
||||
text: pocketConnected ? 'Remove' : 'Connect to Pocket',
|
||||
icon: <Link size={16} weight={'bold'} />,
|
||||
style: 'ctaDarkYellow',
|
||||
style: pocketConnected ? 'ctaWhite' : 'ctaDarkYellow',
|
||||
action: () => {
|
||||
redirectToPocket()
|
||||
pocketConnected
|
||||
? deleteIntegration(pocketConnected.id)
|
||||
: redirectToPocket()
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
}, [readwiseConnected, router, webhooks])
|
||||
}, [integrations])
|
||||
|
||||
return (
|
||||
<SettingsLayout>
|
||||
|
|
|
|||
Loading…
Reference in a new issue