Skip to content

Commit

Permalink
feat: add default model
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Jan 10, 2024
1 parent 09bf1be commit 1884a94
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/src/routes/admin/Market.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,21 @@ type Model = RawModel & {

type MarketForm = Model[];

const initialState: MarketForm = [];

const generateSeed = () => generateRandomChar(8);

const initialState: MarketForm = [{
id: "",
name: "",
free: false,
auth: false,
description: "",
high_context: false,
default: false,
tag: [],
avatar: modelImages[0],
seed: generateSeed(),
}];

function reducer(state: MarketForm, action: any): MarketForm {
switch (action.type) {
case "set":
Expand Down Expand Up @@ -332,10 +343,10 @@ function Market() {
};

useEffect(() => {
if (form.length === 0 && supportModels.length > 0) {
if (supportModels.length > 0 && !sync.current) {
dispatch({ type: "set", payload: [...supportModels] });
sync.current = true;
}
sync.current = true;
}, [supportModels]);

useEffect(() => {
Expand Down

0 comments on commit 1884a94

Please sign in to comment.