fix: failed to search items by rss feed url which has query parameters
* encode uri component of the rss feed url * use descriminated unions to differetiate rss and newsletter subscription
This commit is contained in:
@ -33,7 +33,17 @@ export type Subscription = {
|
||||
failedAt?: string
|
||||
|
||||
fetchContentType?: FetchContentType
|
||||
}
|
||||
} & (
|
||||
| {
|
||||
type: SubscriptionType.NEWSLETTER
|
||||
unsubscribeMailTo?: string
|
||||
unsubscribeHttpUrl?: string
|
||||
}
|
||||
| {
|
||||
type: SubscriptionType.RSS
|
||||
url: string
|
||||
}
|
||||
)
|
||||
|
||||
type SubscriptionsQueryResponse = {
|
||||
error: any
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { FloppyDisk, Pencil, XCircle } from '@phosphor-icons/react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { FormInput } from '../../../components/elements/FormElements'
|
||||
import {
|
||||
@ -22,6 +22,7 @@ import {
|
||||
} from '../../../lib/networking/mutations/updateSubscriptionMutation'
|
||||
import {
|
||||
FetchContentType,
|
||||
Subscription,
|
||||
SubscriptionStatus,
|
||||
SubscriptionType,
|
||||
useGetSubscriptionsQuery,
|
||||
@ -32,9 +33,13 @@ import { formatMessage } from '../../../locales/en/messages'
|
||||
|
||||
export default function Rss(): JSX.Element {
|
||||
const router = useRouter()
|
||||
const { subscriptions, revalidate, isValidating } = useGetSubscriptionsQuery(
|
||||
const subscriptionsResponse = useGetSubscriptionsQuery(
|
||||
SubscriptionType.RSS
|
||||
)
|
||||
const subscriptions = subscriptionsResponse.subscriptions as Array<
|
||||
Subscription & { type: SubscriptionType.RSS }
|
||||
>
|
||||
const { isValidating, revalidate } = subscriptionsResponse
|
||||
const [onDeleteId, setOnDeleteId] = useState<string>('')
|
||||
const [onEditId, setOnEditId] = useState('')
|
||||
const [onEditName, setOnEditName] = useState('')
|
||||
@ -266,7 +271,11 @@ export default function Rss(): JSX.Element {
|
||||
</VStack>
|
||||
}
|
||||
onClick={() => {
|
||||
router.push(`/home?q=in:inbox rss:"${subscription.url}"`)
|
||||
router.push(
|
||||
`/home?q=in:inbox rss:"${encodeURIComponent(
|
||||
subscription.url
|
||||
)}"`
|
||||
)
|
||||
}}
|
||||
// extraElement={
|
||||
// <HStack
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
import { Tag } from '@phosphor-icons/react'
|
||||
import * as Switch from '@radix-ui/react-switch'
|
||||
import { styled } from '@stitches/react'
|
||||
import { useCallback, useEffect, useMemo, useReducer } from 'react'
|
||||
import { SettingsLayout } from '../../components/templates/SettingsLayout'
|
||||
import { styled } from '../../components/tokens/stitches.config'
|
||||
import { CoverImage } from '../../components/elements/CoverImage'
|
||||
import { FollowingIcon } from '../../components/elements/icons/FollowingIcon'
|
||||
import { NewsletterIcon } from '../../components/elements/icons/NewsletterIcon'
|
||||
import {
|
||||
Box,
|
||||
VStack,
|
||||
HStack,
|
||||
SpanBox,
|
||||
Separator,
|
||||
SpanBox,
|
||||
VStack,
|
||||
} from '../../components/elements/LayoutPrimitives'
|
||||
import { StyledText } from '../../components/elements/StyledText'
|
||||
import { SubscriptionType } from '../../lib/networking/queries/useGetSubscriptionsQuery'
|
||||
import { CoverImage } from '../../components/elements/CoverImage'
|
||||
import { SettingsLayout } from '../../components/templates/SettingsLayout'
|
||||
import { useGetLabels } from '../../lib/networking/labels/useLabels'
|
||||
import { SubscriptionType } from '../../lib/networking/queries/useGetSubscriptionsQuery'
|
||||
import { useGetSavedSearches } from '../../lib/networking/savedsearches/useSavedSearches'
|
||||
import {
|
||||
Shortcut,
|
||||
@ -19,12 +23,8 @@ import {
|
||||
useGetShortcuts,
|
||||
useSetShortcuts,
|
||||
} from '../../lib/networking/shortcuts/useShortcuts'
|
||||
import * as Switch from '@radix-ui/react-switch'
|
||||
import { useGetSubscriptions } from '../../lib/networking/subscriptions/useGetSubscriptions'
|
||||
import { NewsletterIcon } from '../../components/elements/icons/NewsletterIcon'
|
||||
import { FollowingIcon } from '../../components/elements/icons/FollowingIcon'
|
||||
import { escapeQuotes } from '../../utils/helper'
|
||||
import { Tag } from '@phosphor-icons/react'
|
||||
|
||||
function flattenShortcuts(shortcuts: Shortcut[]): string[] {
|
||||
let result: string[] = []
|
||||
@ -288,7 +288,7 @@ const Subscriptions = (props: ListProps) => {
|
||||
? `subscription:\"${escapeQuotes(
|
||||
subscription.name
|
||||
)}\"`
|
||||
: `rss:\"${subscription.url}\"`,
|
||||
: `rss:\"${encodeURIComponent(subscription.url)}\"`,
|
||||
}
|
||||
if (checked) {
|
||||
props.dispatchList({
|
||||
|
||||
Reference in New Issue
Block a user