diff --git a/.eslintrc.js b/.eslintrc.js index aa8d586..1d103aa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,6 +13,10 @@ module.exports = { '@typescript-eslint/no-shadow': 'error', 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'error', + 'react-hooks/exhaustive-deps': 'warn', + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], + 'react/require-default-props': 'off', + 'no-use-before-define': 'off', }, parserOptions: { ecmaVersion: 2020, diff --git a/src/main/madara-app.ts b/src/main/madara-app.ts index 5989bc2..3535570 100644 --- a/src/main/madara-app.ts +++ b/src/main/madara-app.ts @@ -1,6 +1,4 @@ -/* eslint-disable no-plusplus */ /* eslint-disable no-await-in-loop */ -/* eslint-disable no-use-before-define */ import { ChildProcess, exec, execSync } from 'child_process'; import { BrowserWindow } from 'electron'; import { download } from 'electron-dl'; diff --git a/src/main/madara.ts b/src/main/madara.ts index 00f7ec6..e6317f7 100644 --- a/src/main/madara.ts +++ b/src/main/madara.ts @@ -86,7 +86,6 @@ export async function setup(window: BrowserWindow, config: MadaraConfig) { const notDownloadedFiles = getNotDownloadedFiles(config); - // eslint-disable-next-line no-plusplus for (let i = 0; i < notDownloadedFiles.length; i++) { const file = notDownloadedFiles[i]; const opts: { diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 31efeaf..cae65c1 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks/exhaustive-deps */ import axios from 'axios'; import { useEffect } from 'react'; import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'; diff --git a/src/renderer/components/Button.tsx b/src/renderer/components/Button.tsx index 66f7047..ec21ca1 100644 --- a/src/renderer/components/Button.tsx +++ b/src/renderer/components/Button.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/require-default-props */ import { styled } from 'styled-components'; const ButtonContainer = styled.button` diff --git a/src/renderer/components/InfiniteBarLoader.tsx b/src/renderer/components/InfiniteBarLoader.tsx index fd5c776..5760448 100644 --- a/src/renderer/components/InfiniteBarLoader.tsx +++ b/src/renderer/components/InfiniteBarLoader.tsx @@ -1,5 +1,4 @@ // taken from here https://csslayout.io/indeterminate-progress-bar/ -/* eslint-disable react/require-default-props */ import { CSSProperties } from 'react'; import { styled } from 'styled-components'; diff --git a/src/renderer/components/Input.tsx b/src/renderer/components/Input.tsx index 998c974..0b3f95d 100644 --- a/src/renderer/components/Input.tsx +++ b/src/renderer/components/Input.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/require-default-props */ import React, { CSSProperties } from 'react'; import { styled } from 'styled-components'; diff --git a/src/renderer/features/appsSlice.ts b/src/renderer/features/appsSlice.ts index 7cd9878..923604b 100644 --- a/src/renderer/features/appsSlice.ts +++ b/src/renderer/features/appsSlice.ts @@ -1,7 +1,12 @@ import { createSlice } from '@reduxjs/toolkit'; import { getStore } from 'renderer/store/storeRegistry'; -const initialState = { +type InstalledApps = { [appId: string]: boolean }; +type RunningApps = { [appId: string]: boolean }; +const initialState: { + installedApps: InstalledApps; + runningApps: RunningApps; +} = { installedApps: {}, runningApps: {}, }; @@ -22,8 +27,9 @@ export const appsSlice = createSlice({ export const { setInstalledApps, setRunningApps } = appsSlice.actions; -export const selectInstalledApps = (state: any) => state.apps.installedApps; -export const selectRunningApps = (state: any) => { +export const selectInstalledApps = (state: any): InstalledApps => + state.apps.installedApps; +export const selectRunningApps = (state: any): RunningApps => { return state.apps.runningApps; }; @@ -45,6 +51,15 @@ export const setupInstalledApps = () => async (dispatch: any) => { dispatch(setInstalledApps(installedApps)); }; +export const closeAllApps = () => async (dispatch: any, getState: any) => { + const runningApps = selectRunningApps(getState()); + Object.entries(runningApps).forEach(([appId, isRunning]) => { + if (isRunning) { + window.electron.ipcRenderer.madaraApp.stopApp(appId); + } + }); +}; + // listener to know when an app is running window.electron.ipcRenderer.madaraApp.onAppStart( (event: any, data: { appId: string }) => diff --git a/src/renderer/features/nodeSlice.ts b/src/renderer/features/nodeSlice.ts index cd72d75..01e59f2 100644 --- a/src/renderer/features/nodeSlice.ts +++ b/src/renderer/features/nodeSlice.ts @@ -1,6 +1,7 @@ import { createSlice } from '@reduxjs/toolkit'; import { MadaraConfig } from 'main/types'; import { getStore } from 'renderer/store/storeRegistry'; +import { closeAllApps } from './appsSlice'; export type configTypes = | 'RPCCors' @@ -106,6 +107,7 @@ export const stopNode = () => async (dispatch: any, getState: any) => { export const deleteNode = () => async (dispatch: any) => { dispatch(setIsRunning(false)); dispatch(setLogs('')); + dispatch(closeAllApps()); await window.electron.ipcRenderer.madara.delete(); }; diff --git a/src/renderer/features/walletSlice.ts b/src/renderer/features/walletSlice.ts index 7a525c4..551062d 100644 --- a/src/renderer/features/walletSlice.ts +++ b/src/renderer/features/walletSlice.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-use-before-define */ import { createSlice } from '@reduxjs/toolkit'; import * as starknet from 'starknet'; import erc20Abi from '../../../config/abi/erc20.json'; diff --git a/src/renderer/pages/Apps.tsx b/src/renderer/pages/Apps.tsx index 3b20a1c..3c39410 100644 --- a/src/renderer/pages/Apps.tsx +++ b/src/renderer/pages/Apps.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks/exhaustive-deps */ import { faPause, faPlay } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Progress } from 'electron-dl'; diff --git a/src/renderer/pages/Telemetry.tsx b/src/renderer/pages/Telemetry.tsx index 4a9d94b..4936f4a 100644 --- a/src/renderer/pages/Telemetry.tsx +++ b/src/renderer/pages/Telemetry.tsx @@ -1,6 +1,8 @@ import { AnimatePresence, motion } from 'framer-motion'; import { useEffect, useState } from 'react'; import InfiniteBarLoader from 'renderer/components/InfiniteBarLoader'; +import { selectConfig } from 'renderer/features/nodeSlice'; +import { useAppSelector } from 'renderer/utils/hooks'; import { styled } from 'styled-components'; const TelemetryContainer = styled.div` @@ -39,15 +41,11 @@ const BANNER_SEEN_KEY = 'banner_seen'; export default function Telemetry() { const [loading, setLoading] = useState(true); const [isBannerVisible, setIsBannerVisible] = useState(false); + const nodeConig = useAppSelector(selectConfig); useEffect(() => { - const bannerSeen = sessionStorage.getItem(BANNER_SEEN_KEY); - if (bannerSeen === 'true') { - setIsBannerVisible(false); - } else { - setIsBannerVisible(true); - setTimeout(() => setIsBannerVisible(false), 5000); - } + setIsBannerVisible(true); + setTimeout(() => setIsBannerVisible(false), 5000); }, []); const handleLoad = () => { @@ -76,8 +74,10 @@ export default function Telemetry() { exit={{ y: '200%' }} > - It can take a few minutes for your node to reflect here. Kindly - check the Logs for any errors + {nodeConig.testnet !== 'sharingan' + ? `You must set the testnet to "sharingan" to see your node here.` + : `It can take a few minutes for your node to reflect here. Kindly + check the Logs for any errors`} )} diff --git a/src/renderer/pages/Wallet.tsx b/src/renderer/pages/Wallet.tsx index 0488df4..01382be 100644 --- a/src/renderer/pages/Wallet.tsx +++ b/src/renderer/pages/Wallet.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks/exhaustive-deps */ import { useEffect } from 'react'; import Button from 'renderer/components/Button'; import Input from 'renderer/components/Input';