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