fix: update empty category correctly
This commit is contained in:
@@ -115,7 +115,7 @@ export const useBatchUpdateSubscription = () => {
|
||||
view,
|
||||
}: {
|
||||
feedIdList: string[]
|
||||
category: string
|
||||
category?: string | null
|
||||
view: number
|
||||
}) => {
|
||||
await subscriptionActions.batchUpdateSubscription({
|
||||
|
||||
@@ -122,7 +122,7 @@ export function Component() {
|
||||
}
|
||||
|
||||
const { category, view } = event.over.data.current as {
|
||||
category: string
|
||||
category?: string | null
|
||||
view: FeedViewType
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ class SubscriptionServiceStatic extends BaseService<SubscriptionModelWithId> imp
|
||||
return this.table.where("feedId").anyOf(feedIdList).modify({ view })
|
||||
}
|
||||
|
||||
async updateCategory(feedId: string, category: string) {
|
||||
async updateCategory(feedId: string, category?: string | null) {
|
||||
return this.table.where("feedId").equals(feedId).modify({ category })
|
||||
}
|
||||
async updateCategories(feedIdList: string[], category: string) {
|
||||
async updateCategories(feedIdList: string[], category?: string | null) {
|
||||
return this.table.where("feedId").anyOf(feedIdList).modify({ category })
|
||||
}
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@ class SubscriptionActions {
|
||||
view,
|
||||
}: {
|
||||
feedIdList: string[]
|
||||
category: string
|
||||
category?: string | null
|
||||
view: FeedViewType
|
||||
}) {
|
||||
const tx = createTransaction<
|
||||
@@ -568,6 +568,13 @@ class SubscriptionActions {
|
||||
if (!subscription) return
|
||||
|
||||
subscription.category = category
|
||||
const feed = getFeedById(feedId)
|
||||
if (feed?.type === "feed" && feed.siteUrl) {
|
||||
const parsed = parse(feed.siteUrl)
|
||||
if (parsed.domain) {
|
||||
subscription.defaultCategory = capitalizeFirstLetter(parsed.domain)
|
||||
}
|
||||
}
|
||||
|
||||
if (subscription.view !== view) {
|
||||
const currentViewFeedIds = draft.feedIdByView[subscription.view] as string[]
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
|
||||
export function useKeyPressing(key: string) {
|
||||
const [keysPressed, setKeysPressed] = useState(() => new Set())
|
||||
const [keysPressed, setKeysPressed] = useState<string[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
setKeysPressed((prev) => {
|
||||
const newSet = new Set(prev)
|
||||
newSet.add(event.key)
|
||||
return newSet
|
||||
if (!prev.includes(event.key)) {
|
||||
return [...prev, event.key]
|
||||
}
|
||||
return prev
|
||||
})
|
||||
}
|
||||
|
||||
const handleKeyUp = (event: KeyboardEvent) => {
|
||||
setKeysPressed((prev) => {
|
||||
const newSet = new Set(prev)
|
||||
newSet.delete(event.key)
|
||||
return newSet
|
||||
return prev.filter((key) => key !== event.key)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,5 +28,5 @@ export function useKeyPressing(key: string) {
|
||||
}
|
||||
}, [])
|
||||
|
||||
return useMemo(() => keysPressed.has(key), [keysPressed, key])
|
||||
return useMemo(() => keysPressed.includes(key), [keysPressed, key])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user