Commit d49f1d95 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/feedback' into 'main'

修复组卡页卡组全删后出现的crash,卡片选择弹窗区分敌我卡片

See merge request !297
parents 07eb4ed6 78548c51
Pipeline #23382 passed with stages
in 13 minutes and 41 seconds
......@@ -13,6 +13,8 @@ export interface IDeck {
side: number[];
}
export const emptyDeck: IDeck = { deckName: "", main: [], extra: [], side: [] };
export const deckStore = proxy({
decks: [] as IDeck[],
......
import { proxy } from "valtio";
import { IDeck } from "./deckStore";
import { emptyDeck, IDeck } from "./deckStore";
import { type NeosStore } from "./shared";
export enum SideStage {
......@@ -13,8 +13,6 @@ export enum SideStage {
WAITING = 8, // 观战者等待双方玩家
}
const emptyDeck: IDeck = { deckName: "", main: [], extra: [], side: [] };
class SideStore implements NeosStore {
stage: SideStage = SideStage.NONE;
deck: IDeck = emptyDeck;
......
......@@ -29,7 +29,7 @@ import { subscribeKey } from "valtio/utils";
import { type CardMeta, searchCards } from "@/api";
import { isExtraDeckCard, isToken } from "@/common";
import { FtsConditions } from "@/middleware/sqlite/fts";
import { deckStore, type IDeck, initStore } from "@/stores";
import { deckStore, emptyDeck, type IDeck, initStore } from "@/stores";
import {
Background,
DeckCard,
......@@ -74,7 +74,9 @@ export const loader: LoaderFunction = async () => {
export const Component: React.FC = () => {
const snapDecks = useSnapshot(deckStore);
const { progress } = useSnapshot(initStore.sqlite);
const [selectedDeck, setSelectedDeck] = useState<IDeck>(deckStore.decks[0]);
const [selectedDeck, setSelectedDeck] = useState<IDeck>(
deckStore.decks.at(0) ?? emptyDeck,
);
const { message } = App.useApp();
......@@ -107,7 +109,7 @@ export const Component: React.FC = () => {
decks={snapDecks.decks}
selected={selectedDeck.deckName}
onSelect={(name) =>
setSelectedDeck(deckStore.get(name) ?? deckStore.decks[0])
setSelectedDeck(deckStore.get(name) ?? emptyDeck)
}
onDelete={async (name) => await deckStore.delete(name)}
onDownload={(name) => {
......
......@@ -45,6 +45,13 @@
margin-inline-end: 0;
margin-block-end: 0;
flex-shrink: 0;
&.opponent {
&::before {
background-color: #dc003433;
box-shadow: 0 0 0 2px #d22d2d inset;
}
}
}
.card {
......
import { CheckCard } from "@ant-design/pro-components";
import { Button, Card, Segmented, Space, Tooltip } from "antd";
import classnames from "classnames";
import { useEffect, useState } from "react";
import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio";
import { type CardMeta, Region, type ygopro } from "@/api";
import { fetchStrings } from "@/api";
import { CardType, matStore } from "@/stores";
import { CardType, isMe, matStore } from "@/stores";
import { YgoCard } from "@/ui/Shared";
import { groupBy } from "../../utils";
......@@ -176,7 +177,11 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
className={styles.card}
/>
}
className={styles["check-card"]}
className={classnames(styles["check-card"], {
[styles.opponent]:
card.location?.controller !== undefined &&
!isMe(card.location.controller),
})}
value={card}
onClick={() => {
showCardModal(card);
......
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