]> git.localhorst.tv Git - alttp.git/commitdiff
only show DNFs for finished players
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 15 Mar 2022 18:30:18 +0000 (19:30 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 15 Mar 2022 18:30:18 +0000 (19:30 +0100)
resources/js/components/results/Item.js

index 0d0d34e81a11553f7535be8a883d1fabb7df378d..2a1fc8c07f4cbb404be0f030b0315e274720dc33 100644 (file)
@@ -9,11 +9,11 @@ import { findResult } from '../../helpers/Participant';
 import { maySeeResults } from '../../helpers/permissions';
 import { withUser } from '../../helpers/UserContext';
 
-const getIcon = (result, index) => {
+const getIcon = (result, index, maySee) => {
        if (!result || !result.has_finished) {
                return <Icon.PENDING className="text-muted" size="lg" />;
        }
-       if (result.forfeit) {
+       if (result.forfeit && maySee) {
                return <Icon.FORFEIT className="text-danger" size="lg" />;
        }
        if (index === 0) {
@@ -28,8 +28,8 @@ const getIcon = (result, index) => {
        return <Icon.FINISHED className="text-success" size="lg" />;
 };
 
-const getTime = (user, tournament, round, result) => {
-       if (!result || !maySeeResults(user, tournament, round)) {
+const getTime = (result, maySee) => {
+       if (!result || !maySee) {
                return null;
        }
        if (result.time) {
@@ -49,13 +49,14 @@ const Item = ({
        user,
 }) => {
        const result = findResult(participant, round);
+       const maySee = maySeeResults(user, tournament, round);
        return <div className="result">
                <Box user={participant.user} />
                <div className="status">
                        <span className="time">
-                               {getTime(user, tournament, round, result)}
+                               {getTime(result, maySee)}
                        </span>
-                       {getIcon(result, index)}
+                       {getIcon(result, index, maySee)}
                </div>
        </div>;
 };