Skip to content

Commit

Permalink
fix: allow click when selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Nov 11, 2024
1 parent 3b9b61d commit c514458
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
4 changes: 2 additions & 2 deletions apps/renderer/src/modules/feed-column/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
const selectoRef = useRef<Selecto>(null)
const [selectedFeedIds, setSelectedFeedIds] = useSelectedFeedIds()

const { attributes, listeners, setNodeRef, transform, isDragging } = useDraggable({
const { attributes, listeners, setNodeRef, transform } = useDraggable({
id: "selected-feed",
disabled: selectedFeedIds.length === 0,
})
Expand Down Expand Up @@ -198,7 +198,7 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
ref={selectoRef}
rootContainer={document.body}
dragContainer={"#feeds-area"}
dragCondition={() => !(selectedFeedIds.length > 0 && isDragging)}
dragCondition={() => selectedFeedIds.length === 0}
selectableTargets={["[data-feed-id]"]}
continueSelect
hitRate={10}
Expand Down
44 changes: 28 additions & 16 deletions apps/renderer/src/pages/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DndContext, pointerWithin } from "@dnd-kit/core"
import type { DragEndEvent } from "@dnd-kit/core"
import { DndContext, PointerSensor, pointerWithin, useSensor, useSensors } from "@dnd-kit/core"
import { useViewport } from "@follow/components/hooks/useViewport.js"
import { PanelSplitter } from "@follow/components/ui/divider/index.js"
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
Expand Down Expand Up @@ -105,9 +106,32 @@ export function Component() {
const { data: remoteSettings, isLoading } = useAuthQuery(settings.get(), {})
const isNewUser = !isLoading && remoteSettings && Object.keys(remoteSettings.updated).length === 0

const sensors = useSensors(
useSensor(PointerSensor, {
activationConstraint: {
distance: 8,
},
}),
)
const [selectedIds, setSelectedIds] = useSelectedFeedIds()

const { mutate } = useBatchUpdateSubscription()
const handleDragEnd = React.useCallback(
(event: DragEndEvent) => {
if (!event.over) {
return
}

const { category, view } = event.over.data.current as {
category: string
view: FeedViewType
}

mutate({ category, view, feedIdList: selectedIds })

setSelectedIds([])
},
[mutate, selectedIds, setSelectedIds],
)

if (isNotSupportWidth) {
return <NotSupport />
Expand All @@ -123,21 +147,9 @@ export function Component() {
<AppLayoutGridContainerProvider>
<FeedResponsiveResizerContainer containerRef={containerRef}>
<DndContext
sensors={sensors}
collisionDetection={pointerWithin}
onDragEnd={(event) => {
if (!event.over) {
return
}

const { category, view } = event.over.data.current as {
category: string
view: FeedViewType
}

mutate({ category, view, feedIdList: selectedIds })

setSelectedIds([])
}}
onDragEnd={handleDragEnd}
>
<FeedColumn>
<CornerPlayer />
Expand Down

0 comments on commit c514458

Please sign in to comment.