mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 20:22:39 +08:00
fix: refresh list on delete (#178)
This commit is contained in:
@@ -16,10 +16,12 @@ import AppsContext from '@/context/app-context'
|
||||
|
||||
export type AppCardProps = {
|
||||
app: App
|
||||
onDelete?: () => void
|
||||
}
|
||||
|
||||
const AppCard = ({
|
||||
app,
|
||||
onDelete
|
||||
}: AppCardProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { notify } = useContext(ToastContext)
|
||||
@@ -35,6 +37,8 @@ const AppCard = ({
|
||||
try {
|
||||
await deleteApp(app.id)
|
||||
notify({ type: 'success', message: t('app.appDeleted') })
|
||||
if (onDelete)
|
||||
onDelete()
|
||||
mutateApps()
|
||||
}
|
||||
catch (e: any) {
|
||||
@@ -47,7 +51,7 @@ const AppCard = ({
|
||||
<>
|
||||
<Link href={`/app/${app.id}/overview`} className={style.listItem}>
|
||||
<div className={style.listItemTitle}>
|
||||
<AppIcon size='small' icon={app.icon} background={app.icon_background}/>
|
||||
<AppIcon size='small' icon={app.icon} background={app.icon_background} />
|
||||
<div className={style.listItemHeading}>
|
||||
<div className={style.listItemHeadingContent}>{app.name}</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,9 @@ const Apps = () => {
|
||||
|
||||
return (
|
||||
<nav className='grid content-start grid-cols-1 gap-4 px-12 pt-8 sm:grid-cols-2 lg:grid-cols-4 grow shrink-0'>
|
||||
{data?.map(({ data: apps }) => apps.map(app => (<AppCard key={app.id} app={app} />)))}
|
||||
{data?.map(({ data: apps }) => apps.map(app => (
|
||||
<AppCard key={app.id} app={app} onDelete={mutate} />
|
||||
)))}
|
||||
<NewAppCard ref={anchorRef} onSuccess={mutate} />
|
||||
</nav>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user