mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix some issues with unsubscribing on web
This commit is contained in:
parent
3ab9e41b82
commit
9618e452bc
4 changed files with 34 additions and 29 deletions
|
|
@ -81,14 +81,14 @@ export function CardMenu(props: CardMenuProps): JSX.Element {
|
|||
}}
|
||||
title="Remove"
|
||||
/>
|
||||
{!!props.item.subscription && (
|
||||
{/* {!!props.item.subscription && (
|
||||
<DropdownOption
|
||||
onSelect={() => {
|
||||
props.actionHandler('unsubscribe')
|
||||
}}
|
||||
title="Unsubscribe"
|
||||
/>
|
||||
)}
|
||||
)} */}
|
||||
</Dropdown>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@ type ConfirmationModalProps = {
|
|||
export function ConfirmationModal(props: ConfirmationModalProps): JSX.Element {
|
||||
const safeOnOpenChange = useCallback(
|
||||
(open: boolean) => {
|
||||
props.onOpenChange(open)
|
||||
setTimeout(() => {
|
||||
console.log('body style: ', document.body.style)
|
||||
document.body.style.removeProperty('pointer-events')
|
||||
}, 200)
|
||||
props.onOpenChange(open)
|
||||
},
|
||||
[props]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ type Unsubscribe = {
|
|||
}
|
||||
|
||||
export async function unsubscribeMutation(
|
||||
subscribeName: string,
|
||||
id = ''
|
||||
subscribtionName: string,
|
||||
id: string
|
||||
): Promise<any | undefined> {
|
||||
const mutation = gql`
|
||||
mutation {
|
||||
unsubscribe(name: "${subscribeName}", subscriptionId: "${id}") {
|
||||
mutation Unsubscribe($subscribtionName: String!, $subscriptionId: ID!) {
|
||||
unsubscribe(name: $subscribtionName, subscriptionId: $subscriptionId) {
|
||||
... on UnsubscribeSuccess {
|
||||
subscription {
|
||||
id
|
||||
|
|
@ -31,7 +31,11 @@ export async function unsubscribeMutation(
|
|||
`
|
||||
|
||||
try {
|
||||
const data = (await gqlFetcher(mutation)) as UnsubscribeResult
|
||||
const data = (await gqlFetcher(mutation, {
|
||||
subscriptionId: id,
|
||||
subscribtionName: subscribtionName,
|
||||
})) as UnsubscribeResult
|
||||
|
||||
return data.unsubscribe.errorCodes
|
||||
? undefined
|
||||
: data.unsubscribe.subscription.id
|
||||
|
|
|
|||
|
|
@ -413,27 +413,27 @@ export function useGetLibraryItemsQuery({
|
|||
readingProgressAnchorIndex: 0,
|
||||
})
|
||||
break
|
||||
case 'unsubscribe':
|
||||
if (!!item.node.subscription) {
|
||||
updateData({
|
||||
cursor: item.cursor,
|
||||
node: {
|
||||
...item.node,
|
||||
subscription: undefined,
|
||||
},
|
||||
})
|
||||
unsubscribeMutation(item.node.subscription).then((res) => {
|
||||
if (res) {
|
||||
showSuccessToast('Unsubscribed successfully', {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
} else {
|
||||
showErrorToast('Error unsubscribing', {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
// case 'unsubscribe':
|
||||
// if (!!item.node.subscription) {
|
||||
// updateData({
|
||||
// cursor: item.cursor,
|
||||
// node: {
|
||||
// ...item.node,
|
||||
// subscription: undefined,
|
||||
// },
|
||||
// })
|
||||
// unsubscribeMutation(item.node.subscription).then((res) => {
|
||||
// if (res) {
|
||||
// showSuccessToast('Unsubscribed successfully', {
|
||||
// position: 'bottom-right',
|
||||
// })
|
||||
// } else {
|
||||
// showErrorToast('Error unsubscribing', {
|
||||
// position: 'bottom-right',
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
case 'update-item':
|
||||
updateData(item)
|
||||
break
|
||||
|
|
|
|||
Loading…
Reference in a new issue