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