From 279f8d568146387df842d9a92c33289d6e673afc Mon Sep 17 00:00:00 2001 From: takatost Date: Tue, 9 Jul 2024 17:28:50 +0800 Subject: [PATCH] Optimiz max_active_requests check & remove the max_active_requests input box from app edit form --- api/services/app_service.py | 4 +++- .../explore/create-app-modal/index.tsx | 22 ------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/api/services/app_service.py b/api/services/app_service.py index 76c88754d95494..c4c63e6d066d0b 100644 --- a/api/services/app_service.py +++ b/api/services/app_service.py @@ -325,7 +325,9 @@ def update_app(self, app: App, args: dict) -> App: """ app.name = args.get('name') app.description = args.get('description', '') - app.max_active_requests = args.get('max_active_requests', 0) + app.max_active_requests = args.get('max_active_requests', 0) or 0 + if app.max_active_requests < 0: + app.max_active_requests = 0 app.icon = args.get('icon') app.icon_background = args.get('icon_background') app.updated_at = datetime.now(timezone.utc).replace(tzinfo=None) diff --git a/web/app/components/explore/create-app-modal/index.tsx b/web/app/components/explore/create-app-modal/index.tsx index 4d8bad6c77cc13..714123c5722d39 100644 --- a/web/app/components/explore/create-app-modal/index.tsx +++ b/web/app/components/explore/create-app-modal/index.tsx @@ -1,5 +1,4 @@ 'use client' -import type { ChangeEvent } from 'react' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiCloseLine } from '@remixicon/react' @@ -15,7 +14,6 @@ export type CreateAppModalProps = { show: boolean isEditModal?: boolean appName: string - maxActiveRequests: number appDescription: string appIcon: string appIconBackground: string @@ -23,7 +21,6 @@ export type CreateAppModalProps = { name: string icon: string icon_background: string - max_active_requests: number description: string }) => Promise onHide: () => void @@ -35,7 +32,6 @@ const CreateAppModal = ({ appIcon, appIconBackground, appName, - maxActiveRequests, appDescription, onConfirm, onHide, @@ -43,12 +39,6 @@ const CreateAppModal = ({ const { t } = useTranslation() const [name, setName] = React.useState(appName) - const [max_active_requests, setMaxActiveRequests] = useState(maxActiveRequests) - const handleMaxActiveRequestsChange = (e: ChangeEvent) => { - const value = e.target.value - if (value === '' || (parseInt(value) >= 0 && !value.startsWith('-'))) - setMaxActiveRequests(parseInt(value)) - } const [showEmojiPicker, setShowEmojiPicker] = useState(false) const [emoji, setEmoji] = useState({ icon: appIcon, icon_background: appIconBackground }) const [description, setDescription] = useState(appDescription || '') @@ -64,7 +54,6 @@ const CreateAppModal = ({ onConfirm({ name, ...emoji, - max_active_requests, description, }) onHide() @@ -100,17 +89,6 @@ const CreateAppModal = ({ /> - {/* max active requests */} -
-
{t('app.newApp.appMaxActiveRequests')}
- -
{/* description */}
{t('app.newApp.captionDescription')}