Skip to content

Commit

Permalink
refactor: wrap long ternary to be more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecologne committed Mar 17, 2021
1 parent 3d41b67 commit 602b207
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/instruments/src/Clock/Components/Chrono.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useInteractionEvent } from '../../Common/hooks';
import { useSimVar } from '../../Common/simVars';

const getDisplayString = (seconds: number | null, running: boolean) : string => (seconds == null ? ''
: `${Math.floor(Math.min(seconds, 5999) / 60).toString().padStart(2, '0')}${running ? ':' : ' '}${(Math.floor(Math.min(seconds, 5999) % 60)).toString().padStart(2, '0')}`);
: `${Math.floor(Math.min(seconds, 5999) / 60).toString().padStart(2, '0')}
${running ? ':' : ' '}${(Math.floor(Math.min(seconds, 5999) % 60)).toString().padStart(2, '0')}`);

export const Chrono = () => {
const [ltsTest] = useSimVar('L:XMLVAR_LTS_Test', 'bool', 250);
Expand Down
3 changes: 2 additions & 1 deletion src/instruments/src/Clock/Components/ElapsedTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useEffect, useState } from 'react';
import { useInteractionSimVar, useSimVar } from '../../Common/simVars';

const getDisplayString = (seconds: number, running: boolean) : string => (seconds === 0 && !running ? ''
: `${Math.floor(Math.min(seconds, 359940) / 3600).toString().padStart(2, '0')}${running ? ':' : ' '}${(Math.floor((Math.min(seconds, 359940) % 3600) / 60)).toString().padStart(2, '0')}`);
: `${Math.floor(Math.min(seconds, 359940) / 3600).toString().padStart(2, '0')}
${running ? ':' : ' '}${(Math.floor((Math.min(seconds, 359940) % 3600) / 60)).toString().padStart(2, '0')}`);

export const ElapsedTime = () => {
const [ltsTest] = useSimVar('L:XMLVAR_LTS_Test', 'bool', 250);
Expand Down

0 comments on commit 602b207

Please sign in to comment.