Skip to content

Commit

Permalink
fix: remove currentSpace session (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizy committed Feb 23, 2023
1 parent ad351eb commit 18f9eb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/pages/ServiceManage/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const mapDispatch: any = (dispatch: IDispatch) => ({
const mapState = (state: IRootState) => ({
spaces: state.nebula.spaces,
currentSpace: state.nebula.currentSpace,
nebulaConnect: state.nebula.nebulaConnect,
});

interface IHaderProps {
Expand All @@ -54,7 +53,7 @@ const OverviewCardHeader = (props: IHaderProps) => {
</div>
);
};

let interval;
const Overview: React.FC<IProps> = (props: IProps) => {

const { cluster, currentSpace, spaces, baseRouter = '/management', nebulaConnect } = props;
Expand All @@ -63,13 +62,10 @@ const Overview: React.FC<IProps> = (props: IProps) => {
const [hosts, setHosts] = useState([]);
const nebulaRef = useRef<{
currentSpace: any;
nebulaConnect: any;
}>({
currentSpace,
nebulaConnect,
});
nebulaRef.current.currentSpace = currentSpace;
nebulaRef.current.nebulaConnect = nebulaConnect;
useEffect(() => {
props.clear();
},[cluster])
Expand Down Expand Up @@ -136,16 +132,18 @@ const Overview: React.FC<IProps> = (props: IProps) => {
};

const getBalanceStatus = async () => {
if (!nebulaRef.current.currentSpace||!nebulaRef.current.nebulaConnect) return false;
if (!nebulaRef.current.currentSpace) return false;
const { code,data } = await props.getJobs();
if (code === 0) {
const hasRunningBalance = data.tables.find(item => item.Command.indexOf("BALANCE") && item.status === 'RUNNING');
setBalancing(hasRunningBalance);
} else {
clearInterval(interval);
}
}

useEffect(() => {
const interval = setInterval(() => {
interval = setInterval(() => {
getBalanceStatus();
}, 2000);
return ()=>{
Expand Down
2 changes: 1 addition & 1 deletion src/store/models/nebula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function NebulaModelWrapper(serviceApi, state, _effects) {
spaces: [] as any,
parts: [],
services: [],
currentSpace: SessionStorageUtil.getItem('currentSpace'),
currentSpace: undefined,
...state,
},
reducers: {
Expand Down

0 comments on commit 18f9eb2

Please sign in to comment.