Commit 1e8a6a2e authored by Chunchi Che's avatar Chunchi Che

fix DeckUploder

parent fd8162b5
Pipeline #23052 passed with stages
in 15 minutes and 29 seconds
......@@ -6,7 +6,7 @@ import {
UploadOutlined,
} from "@ant-design/icons";
import { App, Button, Dropdown, MenuProps, Upload, UploadProps } from "antd";
import React, { useState } from "react";
import React, { useRef, useState } from "react";
import YGOProDeck from "ygopro-deck-encode";
import { deckStore, IDeck } from "@/stores";
......@@ -21,7 +21,7 @@ export const DeckSelect: React.FC<{
onDownload: (deckName: string) => void;
onAdd: () => void;
}> = ({ decks, selected, onSelect, onDelete, onDownload, onAdd }) => {
const [newDeck, setNewDeck] = useState<IDeck | undefined>(undefined);
const newDeck = useRef<IDeck | null>(null);
const { modal } = App.useApp();
const showUploadModal = () => {
const { destroy } = modal.info({
......@@ -32,16 +32,15 @@ export const DeckSelect: React.FC<{
content: (
<DeckUploader
onLoaded={(deck) => {
// 这里不生效,很奇怪
setNewDeck(deck);
newDeck.current = deck;
}}
/>
),
okText: "上传",
onCancel: () => destroy(),
onOk: async () => {
if (newDeck) {
await deckStore.add(newDeck);
if (newDeck.current) {
await deckStore.add(newDeck.current);
}
},
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment