Skip to content

Commit

Permalink
Merge pull request #163 from CryptITAustria/fix-kyc-whitelist
Browse files Browse the repository at this point in the history
Desktop Client: Prevent overwrite of local file cache with default values
  • Loading branch information
CryptITAustria authored May 30, 2024
2 parents 98413b5 + 569aefd commit a9b329b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {AiOutlineInfoCircle} from "react-icons/ai";
export function WhitelistDrawer() {
const setDrawerState = useSetAtom(drawerStateAtom);
const {owners, pools} = useAtomValue(chainStateAtom);
const {data, setData} = useStorage();
const {data} = useStorage();
const [selected, setSelected] = useState<string[]>([]);
const {sentryRunning, stopRuntime} = useOperatorRuntime();
const {publicKey: operatorAddress} = useOperator();
Expand Down Expand Up @@ -82,14 +82,14 @@ export function WhitelistDrawer() {
);

async function handleSubmit() {
await setData({
...data,
whitelistedWallets: selected,
});

setDrawerState(null);

if (stopRuntime) {
void stopRuntime();
void stopRuntime({
...data,
sentryRunning: false,
whitelistedWallets: selected,
});
}
}

Expand Down
10 changes: 7 additions & 3 deletions apps/sentry-client-desktop/src/hooks/useOperatorRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Challenge, NodeLicenseInformation, NodeLicenseStatusMap, operatorRuntime
import {useOperator} from "@/features/operator";
import {atom, useAtom} from "jotai";
import {useEffect, useRef, useState} from "react";
import {useStorage} from "@/features/storage";
import {IData, useStorage} from "@/features/storage";
import log from "electron-log";
import { ethers } from "ethers";

Expand Down Expand Up @@ -70,7 +70,7 @@ export function useOperatorRuntime() {
}
}

async function stopRuntime() {
async function stopRuntime(passedData?: IData) {
if (sentryRunning && stop !== undefined) {
// prevent race conditions from pressing "stop" too fast
const _stop = stop;
Expand All @@ -79,7 +79,11 @@ export function useOperatorRuntime() {
await _stop();
setNodeLicenseStatusMap(new Map<bigint, NodeLicenseInformation>());
setSentryRunning(false);
await setData({...data, sentryRunning: false});
if (passedData) {
await setData(passedData);
} else {
await setData({...data, sentryRunning: false});
}
}
}

Expand Down

0 comments on commit a9b329b

Please sign in to comment.