Skip to content

Commit

Permalink
Refactor delete code
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Sep 1, 2023
1 parent b356f1e commit b39fe62
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions web/ui/src/YBFeed/YBFeedItemComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import { FeedItemText } from './YBFeedItemTextComponent'
import { FeedItemImage } from './YBFeedItemImageComponent'
import { FeedItem } from '.'
import { FeedConnector, FeedItem } from '.'

export interface FeedItemHeadingProps {
item: FeedItem,
Expand All @@ -24,16 +24,14 @@ function YBHeading(props: FeedItemHeadingProps) {
setDeleteModalOpen(true)
}
function doDeleteItem() {
fetch("/api/feed/"+encodeURIComponent(item.feed.name)+"/"+encodeURIComponent(name),{
method: "DELETE",
credentials: "include"
})
.then(() => {
setDeleteModalOpen(false)
if (props.onDelete) {
props.onDelete()
}
})
var connection = new FeedConnector()
connection.DeleteItem(item)
.then(() => {
setDeleteModalOpen(false)
if (props.onDelete) {
props.onDelete()
}
})
}

return (
Expand Down

0 comments on commit b39fe62

Please sign in to comment.