Skip to content

Commit

Permalink
fix: Snappier refresh during deletes
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Aug 30, 2023
1 parent 964542d commit 5f5397c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion web/ui/src/YBFeed/YBFeedComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export function FeedComponent() {
:""}

<YBBreadCrumb />

{!fatal?
<>
{authenticated===true?
Expand Down Expand Up @@ -232,7 +233,7 @@ export function FeedComponent() {
</Modal>

<div className="pasteCard">
<YBPasteCard empty={feedItems.current.length === 0}/>
<YBPasteCard empty={feedItems.current.length === 0} onPaste={update}/>
</div>

<FeedItems items={feedItems.current} onUpdate={update} />
Expand Down
11 changes: 9 additions & 2 deletions web/ui/src/YBFeed/YBFeedItemComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FeedItem } from '.'

export interface FeedItemHeadingProps {
item: FeedItem,
onDelete?: () => void
}
function YBHeading(props: FeedItemHeadingProps) {
const { item } = props
Expand All @@ -27,7 +28,12 @@ function YBHeading(props: FeedItemHeadingProps) {
method: "DELETE",
credentials: "include"
})
.then(() => setDeleteModalOpen(false))
.then(() => {
setDeleteModalOpen(false)
if (props.onDelete) {
props.onDelete()
}
})
}

return (
Expand All @@ -53,6 +59,7 @@ export interface FeedItemProps {
item: FeedItem,
showCopyButton?: boolean
onUpdate?: (item: FeedItemProps) => void
onDelete?: () => void
}

export function YBFeedItem(props: FeedItemProps) {
Expand All @@ -68,7 +75,7 @@ export function YBFeedItem(props: FeedItemProps) {

return(
<div className='item'>
<YBHeading item={item} />
<YBHeading item={item} onDelete={props.onDelete}/>
{component}
</div>
)
Expand Down
3 changes: 2 additions & 1 deletion web/ui/src/YBFeed/YBFeedItemsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { FeedItem, FeedItemProps, YBFeedItem } from './'
export interface FeedItemsProps {
items: FeedItem[],
onUpdate?: (item: FeedItemProps) => void
onDelete?: () => void
}

export function FeedItems(props: FeedItemsProps) {
const { items, onUpdate } = props
return(
<>
{items.map((f:FeedItem) =>
<YBFeedItem item={f} onUpdate={onUpdate} key={f.name}/>
<YBFeedItem item={f} onUpdate={onUpdate} onDelete={props.onDelete} key={f.name}/>
)}
</>
)
Expand Down
2 changes: 2 additions & 0 deletions web/ui/src/YBFeed/YBPasteCardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom'

interface PasteCardProps {
empty?: boolean
onPaste: () => void
}

export function YBPasteCard(props:PasteCardProps) {
Expand Down Expand Up @@ -46,6 +47,7 @@ export function YBPasteCard(props:PasteCardProps) {
})
.then(() => {
setTextFieldValue("")
props.onPaste()
})
}
const handleFinish = () => {
Expand Down

0 comments on commit 5f5397c

Please sign in to comment.