Allow toggling the fetch content type per feed
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { gql } from 'graphql-request'
|
||||
import { gqlFetcher } from '../networkHelpers'
|
||||
import {
|
||||
FetchContentType,
|
||||
Subscription,
|
||||
SubscriptionStatus,
|
||||
} from '../queries/useGetSubscriptionsQuery'
|
||||
@ -28,6 +29,7 @@ export interface UpdateSubscriptionInput {
|
||||
status?: SubscriptionStatus
|
||||
autoAddToLibrary?: boolean
|
||||
isPrivate?: boolean
|
||||
fetchContentType?: FetchContentType
|
||||
}
|
||||
|
||||
export async function updateSubscriptionMutation(
|
||||
|
||||
@ -9,6 +9,12 @@ export enum SubscriptionType {
|
||||
NEWSLETTER = 'NEWSLETTER',
|
||||
}
|
||||
|
||||
export enum FetchContentType {
|
||||
ALWAYS = 'ALWAYS',
|
||||
NEVER = 'NEVER',
|
||||
WHEN_EMPTY = 'WHEN_EMPTY',
|
||||
}
|
||||
|
||||
export type Subscription = {
|
||||
id: string
|
||||
name: string
|
||||
@ -25,7 +31,7 @@ export type Subscription = {
|
||||
lastFetchedAt?: string
|
||||
mostRecentItemDate?: string
|
||||
|
||||
fetchContent?: boolean
|
||||
fetchContentType?: FetchContentType
|
||||
}
|
||||
|
||||
type SubscriptionsQueryResponse = {
|
||||
@ -66,7 +72,7 @@ export function useGetSubscriptionsQuery(
|
||||
createdAt
|
||||
updatedAt
|
||||
lastFetchedAt
|
||||
fetchContent
|
||||
fetchContentType
|
||||
mostRecentItemDate
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import {
|
||||
updateSubscriptionMutation,
|
||||
} from '../../../lib/networking/mutations/updateSubscriptionMutation'
|
||||
import {
|
||||
FetchContentType,
|
||||
SubscriptionStatus,
|
||||
SubscriptionType,
|
||||
useGetSubscriptionsQuery,
|
||||
@ -99,6 +100,23 @@ export default function Rss(): JSX.Element {
|
||||
revalidate()
|
||||
}
|
||||
|
||||
const updateFetchContent = async (
|
||||
id: string,
|
||||
fetchContent: FetchContentType
|
||||
): Promise<void> => {
|
||||
const result = await updateSubscriptionMutation({
|
||||
id,
|
||||
fetchContentType: fetchContent,
|
||||
})
|
||||
|
||||
if (result) {
|
||||
showSuccessToast(`Updated feed fetch rule`)
|
||||
} else {
|
||||
showErrorToast(`Error updating feed fetch rule`)
|
||||
}
|
||||
revalidate()
|
||||
}
|
||||
|
||||
applyStoredTheme()
|
||||
|
||||
return (
|
||||
@ -222,6 +240,31 @@ export default function Rss(): JSX.Element {
|
||||
subscription.mostRecentItemDate
|
||||
)}`}
|
||||
</SpanBox>
|
||||
<select
|
||||
tabIndex={-1}
|
||||
onChange={(event) => {
|
||||
;(async () => {
|
||||
updateFetchContent(
|
||||
subscription.id,
|
||||
event.target.value as FetchContentType
|
||||
)
|
||||
})()
|
||||
}}
|
||||
defaultValue={subscription.fetchContentType}
|
||||
style={{
|
||||
padding: '5px',
|
||||
marginTop: '5px',
|
||||
borderRadius: '6px',
|
||||
minWidth: '196px',
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
}}
|
||||
>
|
||||
<option value="ALWAYS">Fetch link: Always</option>
|
||||
<option value="NEVER">Fetch link: Never</option>
|
||||
<option value="WHEN_EMPTY">Fetch link: When empty</option>
|
||||
</select>
|
||||
</VStack>
|
||||
}
|
||||
onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user