Skip to content

Commit

Permalink
feat: hide ranklist God View button when frozen length is unset
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Nov 14, 2024
1 parent ca439fa commit b007403
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/Ranklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Props extends RouteProps {
contest?: IContest;
competition?: ICompetition;
loading: boolean;
frozenLength: number;
problemNum: number;
problemAliasList?: string;
problemBalloonList?: string;
Expand Down Expand Up @@ -196,6 +197,7 @@ class Ranklist extends React.Component<Props, State> {
rating,
allowGodView,
useScore,
frozenLength,
} = this.props;
const { contentWidth, showAll } = this.state;
// const contentWidth = 0;
Expand Down Expand Up @@ -450,7 +452,7 @@ class Ranklist extends React.Component<Props, State> {
>
Export Ranklist
</a>
{allowGodView && (
{allowGodView && frozenLength > 0 && (
<span
style={{
position: 'absolute',
Expand Down
10 changes: 7 additions & 3 deletions src/pages/competitions/$id/ranklist.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { connect } from 'dva';
import { ReduxProps, RouteProps } from '@/@types/props';
import { Row, Col, Card, Button, Progress } from 'antd';
import { Row, Col, Card, Progress } from 'antd';
import { getPathParamId } from '@/utils/getPathParams';
import pages from '@/configs/pages';
import constants from '@/configs/constants';
Expand All @@ -16,7 +16,7 @@ import PageAnimation from '@/components/PageAnimation';
import tracker from '@/utils/tracker';
import { ContestRatingStatus, contestRatingStatusMap } from '@/configs/contestRatingStatus';
import router from 'umi/router';
import { ICompetition, ICompetitionUser } from '@/common/interfaces/competition';
import { ICompetition, ICompetitionSettings, ICompetitionUser } from '@/common/interfaces/competition';
import { ECompetitionUserRole } from '@/common/enums';

export interface Props extends ReduxProps, RouteProps {
Expand All @@ -26,6 +26,7 @@ export interface Props extends ReduxProps, RouteProps {
selfUserDetail: ICompetitionUser;
detailLoading: boolean;
detail: ICompetition;
settings: ICompetitionSettings;
problemsLoading: boolean;
problems: IFullList<IProblem>;
ranklistLoading: boolean;
Expand Down Expand Up @@ -187,6 +188,7 @@ class CompetitionRanklist extends React.Component<Props, State> {
session,
detailLoading,
detail,
settings,
problems,
ranklistLoading,
ranklist: { rows },
Expand Down Expand Up @@ -232,6 +234,7 @@ class CompetitionRanklist extends React.Component<Props, State> {
data={ranklist}
competition={detail}
loading={ranklistLoading}
frozenLength={settings.frozenLength}
problemNum={problems.count || 0}
problemAliasList={problems.rows?.map((item) => item.alias) || []}
problemBalloonList={problems.rows?.map((item) => (item as ICompetitionProblem).balloonColor) || []}
Expand Down Expand Up @@ -263,8 +266,9 @@ function mapStateToProps(state) {
globalSession: state.session,
session: state.competitions.session[id],
selfUserDetail: state.competitions.selfUserDetail[id],
detailLoading: !!state.loading.effects['competitions/getDetail'],
detailLoading: !!state.loading.effects['competitions/getDetail'] || !!state.loading.effects['competitions/getSettings'],
detail: state.competitions.detail[id],
settings: state.competitions.settings[id],
problemsLoading: !!state.loading.effects['competitions/getProblems'],
problems: state.competitions.problems[id] || {},
ranklistLoading: !!state.loading.effects['competitions/getRanklist'],
Expand Down
1 change: 1 addition & 0 deletions src/pages/contests/$id/ranklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class ContestRanklist extends React.Component<Props, State> {
data={ranklist}
contest={detail}
loading={ranklistLoading}
frozenLength={detail.frozenLength}
problemNum={problems.count || 0}
session={session}
userCellRender={(user) => (
Expand Down

0 comments on commit b007403

Please sign in to comment.