fix: fix cannot select test model when searching
Some checks are pending
CI / Unit tests (push) Waiting to run
CI / commit_lint (push) Waiting to run

This commit is contained in:
JustSong 2025-02-09 19:09:53 +08:00
parent 696265774e
commit aed090dd55

View File

@ -1,16 +1,6 @@
import React, {useEffect, useState} from 'react';
import {useTranslation} from 'react-i18next';
import {
Button,
Dropdown,
Form,
Input,
Label,
Message,
Pagination,
Popup,
Table,
} from 'semantic-ui-react';
import {Button, Dropdown, Form, Input, Label, Message, Pagination, Popup, Table,} from 'semantic-ui-react';
import {Link} from 'react-router-dom';
import {
API,
@ -93,11 +83,7 @@ const ChannelsTable = () => {
const [showPrompt, setShowPrompt] = useState(shouldShowPrompt(promptID));
const [showDetail, setShowDetail] = useState(isShowDetail());
const loadChannels = async (startIdx) => {
const res = await API.get(`/api/channel/?p=${startIdx}`);
const { success, message, data } = res.data;
if (success) {
let localChannels = data.map((channel) => {
const processChannelData = (channel) => {
if (channel.models === '') {
channel.models = [];
channel.test_model = '';
@ -116,7 +102,13 @@ const ChannelsTable = () => {
console.log('channel', channel);
}
return channel;
});
};
const loadChannels = async (startIdx) => {
const res = await API.get(`/api/channel/?p=${startIdx}`);
const {success, message, data} = res.data;
if (success) {
let localChannels = data.map(processChannelData);
if (startIdx === 0) {
setChannels(localChannels);
} else {
@ -301,7 +293,8 @@ const ChannelsTable = () => {
const res = await API.get(`/api/channel/search?keyword=${searchKeyword}`);
const { success, message, data } = res.data;
if (success) {
setChannels(data);
let localChannels = data.map(processChannelData);
setChannels(localChannels);
setActivePage(1);
} else {
showError(message);