Skip to content

Commit 7ff2a18

Browse files
committed
bug fixed
1 parent cb8a9ad commit 7ff2a18

File tree

6 files changed

+230
-90
lines changed

6 files changed

+230
-90
lines changed

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="utf-8" />
66
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
88
<meta name="theme-color" content="#000000" />
99
<meta name="description" content="Web site created using create-react-app" />
1010
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />

src/App.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useContext, useEffect } from "react";
1+
import React, {useEffect } from "react";
22
import "./App.css";
33
import { HashRouter as Router, Route, Routes } from "react-router-dom";
44

55
import { Home, Region } from "./pages";
66
import About from './pages/About';
7-
import { DaemonProvider, useDaemonContext } from "./providers/DaemonProvider";
7+
import { useDaemonContext } from "./providers/DaemonProvider";
88
import { createOrGetWallet } from "./services/wallets";
99
import { getAllNodes, startMiningV2 } from "./services/mining";
1010
import { CoNET_Data } from "./utils/globals";
@@ -18,21 +18,24 @@ function App() {
1818
const { setProfile, setMiningData, allRegions, setClosestRegion } = useDaemonContext();
1919

2020
useEffect(() => {
21-
if (allRegions.length === 0) return
21+
// if (allRegions.length === 0) return
2222

2323
const init = async () => {
2424
await createOrGetWallet();
2525
listenProfileVer(setProfile);
2626

27-
if (!CoNET_Data || !CoNET_Data?.profiles) return
27+
2828

29-
await getAllNodes(allRegions, setClosestRegion);
29+
await getAllNodes(allRegions, setClosestRegion, () => {
30+
if (!CoNET_Data || !CoNET_Data?.profiles) return
31+
startMiningV2(CoNET_Data?.profiles?.[0], allRegions, setMiningData);
32+
});
3033

31-
await startMiningV2(CoNET_Data?.profiles?.[0], allRegions, setMiningData);
34+
3235
};
3336

3437
init();
35-
}, [allRegions]);
38+
}, []);
3639

3740
return (
3841
<div className="App">

src/components/MiningStatus/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const MiningStatus = () => {
88
const [isMiningUp, setIsMiningUp] = useState<boolean>(false);
99

1010
useEffect(() => {
11-
setIsMiningUp(miningData?.status === 200)
11+
if (miningData) {
12+
setIsMiningUp(miningData?.status === 200)
13+
}
14+
1215
}, miningData)
1316

1417
return (
@@ -19,6 +22,7 @@ const MiningStatus = () => {
1922
</div>
2023
<div className="rate">Mining Rate: {miningData?.rate ? miningData.rate : <Skeleton height="14px" width="45px" />}</div>
2124
<div className="miners">Online Miners: {miningData?.online ? miningData.online : <Skeleton height="14px" width="45px" />}</div>
25+
<div className="miners">Online VPN Users: {miningData?.totalUsers ? miningData.totalUsers : <Skeleton height="14px" width="45px" />}</div>
2226
</div>
2327
);
2428
};

src/pages/Home/index.tsx

Lines changed: 119 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,46 @@ import MiningStatus from '../../components/MiningStatus';
99
import BlobWrapper from '../../components/BlobWrapper';
1010
import Menu from '../../components/Menu';
1111
import Skeleton from '../../components/Skeleton';
12-
import { allNodes, closestNodes } from '../../services/mining';
12+
import { allNodes, closestNodes, maxNodes, currentScanNodeNumber } from '../../services/mining';
1313
import { CoNET_Data } from '../../utils/globals';
1414

1515
const Home = () => {
16-
const { profile, sRegion, setSRegion, setAllRegions, allRegions, isRandom, setIsRandom } = useDaemonContext();
16+
const { profile, sRegion, setSRegion, setAllRegions, allRegions, isRandom, setIsRandom} = useDaemonContext();
1717
const [power, setPower] = useState<boolean>(false);
1818
const [isInitialLoading, setIsInitialLoading] = useState<boolean>(true);
1919
const [isConnectionLoading, setIsConnectionLoading] = useState<boolean>(false)
2020
const [isMenuVisible, setIsMenuVisible] = useState<boolean>(false)
2121
const [isWalletCopied, setIsWalletCopied] = useState<boolean>(false);
2222
const [isPrivateKeyCopied, setIsPrivateKeyCopied] = useState<boolean>(false);
2323

24+
const [isPortCopied, setIsPortCopied] = useState<boolean>(false);
25+
const [isServerCopied, setIsServerCopied] = useState<boolean>(false);
26+
const [isPACCopied, setIsPACCopied] = useState<boolean>(false);
27+
const [initPercentage, setInitPercentage] = useState<number>(0);
28+
2429
const navigate = useNavigate();
2530

2631
useEffect(() => {
27-
if (allRegions && allRegions.length > 0) {
28-
setIsInitialLoading(false);
29-
return;
30-
}
32+
const listenGetAllNodes = () => {
33+
34+
const initpercentage = maxNodes ? currentScanNodeNumber*100/maxNodes : 0
35+
const status = Math.round(initpercentage)
36+
setInitPercentage(status)
37+
38+
if (initpercentage < 90) {
39+
return setTimeout(() => {
40+
listenGetAllNodes()
41+
}, 1000)
42+
} else {
43+
setIsInitialLoading(false);
44+
}
45+
46+
47+
}
48+
listenGetAllNodes()
49+
},[])
50+
51+
useEffect(() => {
3152

3253
const _getAllRegions = async () => {
3354
const tmpRegions = await getAllRegions();
@@ -47,10 +68,12 @@ const Home = () => {
4768
setAllRegions(treatedRegions);
4869
};
4970

71+
72+
5073
_getAllRegions()
5174

52-
setTimeout(() => setIsInitialLoading(false), 3000);
53-
}, [allRegions, setAllRegions]);
75+
// setTimeout(() => setIsInitialLoading(false), 3000);
76+
}, [allRegions]);
5477

5578
const toggleMenu = () => {
5679
setIsMenuVisible(prevState => !prevState);
@@ -144,6 +167,10 @@ const Home = () => {
144167
if (power)
145168
return (
146169
<>
170+
<div className="current-mined">
171+
{profile?.tokens?.cCNTP?.balance ? <p>{profile.tokens.cCNTP.balance}</p> : <Skeleton width="127px" height="43px" />}
172+
<p>CNTP</p>
173+
</div>
147174
<p className="connection">Your connection is <span>protected!</span></p>
148175

149176
<BlobWrapper>
@@ -155,15 +182,16 @@ const Home = () => {
155182
</button>
156183
</BlobWrapper>
157184

158-
<div className="current-mined">
159-
{profile?.tokens?.cCNTP?.balance ? <p>{profile.tokens.cCNTP.balance}</p> : <Skeleton width="127px" height="43px" />}
160-
<p>CNTP</p>
161-
</div>
185+
162186
</>
163187
)
164188

165189
return (
166190
<>
191+
<div className="current-mined">
192+
{profile?.tokens?.cCNTP?.balance ? <p>{profile.tokens.cCNTP.balance}</p> : <Skeleton width="127px" height="43px" />}
193+
<p>CNTP</p>
194+
</div>
167195
<p className="connection">Your connection is not protected!</p>
168196

169197
<BlobWrapper>
@@ -175,10 +203,7 @@ const Home = () => {
175203
</button>
176204
</BlobWrapper>
177205

178-
<div className="current-mined">
179-
{profile?.tokens?.cCNTP?.balance ? <p>{profile.tokens.cCNTP.balance}</p> : <Skeleton width="127px" height="43px" />}
180-
<p>CNTP</p>
181-
</div>
206+
182207
</>
183208
)
184209
}
@@ -188,9 +213,10 @@ const Home = () => {
188213

189214
return (
190215
<div className="rs-wrapper">
191-
{
216+
217+
{/* {
192218
!power && <p>Connect via Auto-Select or pick your region</p>
193-
}
219+
} */}
194220
<div className="region-selector">
195221
{
196222
!power && (
@@ -268,6 +294,77 @@ const Home = () => {
268294
)
269295
}
270296

297+
298+
const copyPort = () => {
299+
navigator.clipboard.writeText("8888")
300+
setIsPortCopied(true);
301+
302+
setTimeout(() => {
303+
setIsPortCopied(false);
304+
}, 2000);
305+
}
306+
307+
const copyServer = () => {
308+
navigator.clipboard.writeText("127.0.0.1")
309+
setIsServerCopied(true);
310+
311+
setTimeout(() => {
312+
setIsServerCopied(false);
313+
}, 2000);
314+
}
315+
316+
const copyPAC = () => {
317+
navigator.clipboard.writeText("http://127.0.0.1:8888/pac")
318+
setIsPACCopied(true);
319+
320+
setTimeout(() => {
321+
setIsPACCopied(false);
322+
}, 2000);
323+
}
324+
325+
const proxyInfo = () => {
326+
return (
327+
<>
328+
<div className="wallet-info-container">
329+
<div className="wallet-info">
330+
<p>Proxy Server:</p>
331+
<button onClick={copyServer}>
332+
<p>127.0.0.1</p>
333+
{isServerCopied ? (
334+
<img src="/assets/check.svg" alt="Copy icon" />
335+
) : (
336+
<img src="/assets/copy-purple.svg" alt="Copy icon" />
337+
)}
338+
</button>
339+
</div>
340+
<div className="wallet-info">
341+
<p>Proxy Port:</p>
342+
<button onClick={copyPort}>
343+
<p>8888</p>
344+
{isPortCopied ? (
345+
<img src="/assets/check.svg" alt="Copy icon" />
346+
) : (
347+
<img src="/assets/copy-purple.svg" alt="Copy icon" />
348+
)}
349+
</button>
350+
</div>
351+
<div className="wallet-info">
352+
<p>PAC:</p>
353+
<button onClick={copyPAC}>
354+
<p>http://127.0.0.1:8888/pac</p>
355+
{isPACCopied ? (
356+
<img src="/assets/check.svg" alt="Copy icon" />
357+
) : (
358+
<img src="/assets/copy-purple.svg" alt="Copy icon" />
359+
)}
360+
</button>
361+
362+
</div>
363+
</div>
364+
</>
365+
)
366+
}
367+
271368
const copyWallet = () => {
272369
navigator.clipboard.writeText(profile.keyID);
273370

@@ -318,12 +415,15 @@ const Home = () => {
318415
>
319416
<img className="loading-spinning" src="/assets/silent-pass-logo-grey.png" width={85} height={85} alt="" />
320417
</button>
321-
418+
<p className="not-connected">
419+
Initializing {initPercentage}%
420+
</p>
322421
<p className="not-connected">Welcome to Silent Pass</p>
323422
</>
324423
) : (
325424
<>
326425
{renderButton()}
426+
{power && proxyInfo()}
327427
{renderRegionSelector()}
328428

329429
<div className="wallet-info-container">

0 commit comments

Comments
 (0)