Skip to content

Commit

Permalink
fixes in FleetMovements
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed Jan 2, 2024
1 parent f09ec1f commit 5ee233c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
6 changes: 0 additions & 6 deletions packages/testnet/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"webfontloader": "^1.6.28"
},
"devDependencies": {
"@scure/base": "^1.1.5",
"@types/node": "^20.10.5",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
Expand All @@ -44,11 +43,6 @@
"axios": "^1.6.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "^5.3.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import styled from 'styled-components';
import * as Styled from '../../shared/styled/Box';
import { CircularProgress } from '@mui/material';
Expand All @@ -17,7 +17,6 @@ import {
import { DebrisFieldView } from '../ui/DebrisFieldView';
import { useTechsLevels } from '../../hooks/LevelsHooks';
import { usePlanetPosition } from '../../hooks/usePlanetPosition';
import { useMemo } from 'react';

const InfoContainer = styled(Styled.InfoContainer)({
width: '45%',
Expand Down
24 changes: 13 additions & 11 deletions packages/testnet/frontend/src/components/ui/FleetMovements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ const fleetReducer = (state: FleetState, action: FleetAction): FleetState => {
newDecays[action.payload.index] = action.payload.decay;
return { ...state, decayPercentages: newDecays };
}
case 'UPDATE_MISSION': {
const newCountdowns = [...state.countdowns];
const newDecays = [...state.decayPercentages];

newCountdowns[action.payload.index] = action.payload.countdown;
newDecays[action.payload.index] = action.payload.decay;

return {
...state,
countdowns: newCountdowns,
decayPercentages: newDecays,
};
}
default:
return state;
}
Expand Down Expand Up @@ -141,11 +154,6 @@ export const FleetMovements = ({ planetId }: Props) => {
const currentTime = Date.now();
const differenceInSeconds = (arrivalTime - currentTime) / 1000;

// For debugging: log the times and calculated difference
console.log('Arrival time:', arrivalTime);
console.log('Current time:', currentTime);
console.log('Difference in seconds:', differenceInSeconds);

if (differenceInSeconds <= 0) {
return 'Arrived';
}
Expand All @@ -158,16 +166,11 @@ export const FleetMovements = ({ planetId }: Props) => {
}, []);

useEffect(() => {
console.log('useEffect called'); // Check if useEffect is called
console.log('missions inside useEffect', missions); // Check the missions array inside useEffect
// Array to keep track of interval IDs
const intervalIDs: ReturnType<typeof setInterval>[] = [];

missions.forEach((mission, index) => {
console.log('missions inside useEffect', missions);

if (missions.length === 0) {
console.log('No missions to set intervals for');
return;
}
const intervalID = setInterval(() => {
Expand Down Expand Up @@ -197,7 +200,6 @@ export const FleetMovements = ({ planetId }: Props) => {

// Clear intervals when the component unmounts or when missions change
return () => {
console.log('Cleaning up intervals');
intervalIDs.forEach(clearInterval);
};
}, [getTimeDifference, missions]);
Expand Down
3 changes: 1 addition & 2 deletions packages/testnet/frontend/src/components/ui/WalletBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import React, { useMemo } from 'react';
import { useAccount, useConnect } from '@starknet-react/core';
import { useMemo } from 'react';

function WalletConnected() {
const { address } = useAccount();
Expand Down

0 comments on commit 5ee233c

Please sign in to comment.