mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-23 19:37:52 +00:00
logout event
This commit is contained in:
parent
3e0d3394e2
commit
9e32cb4e67
@ -956,8 +956,8 @@ function App() {
|
|||||||
.sendMessage("logout", {})
|
.sendMessage("logout", {})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
resetAllStates();
|
|
||||||
executeEvent("logout-event", {});
|
executeEvent("logout-event", {});
|
||||||
|
resetAllStates();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { getBaseApiReactSocket, pauseAllQueues, resumeAllQueues } from '../../App';
|
import { getBaseApiReactSocket, pauseAllQueues, resumeAllQueues } from '../../App';
|
||||||
|
import { subscribeToEvent, unsubscribeFromEvent } from '../../utils/events';
|
||||||
|
|
||||||
export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
||||||
const socketRef = useRef(null); // WebSocket reference
|
const socketRef = useRef(null); // WebSocket reference
|
||||||
@ -16,6 +17,18 @@ export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logoutEventFunc = () => {
|
||||||
|
forceCloseWebSocket()
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
subscribeToEvent("logout-event", logoutEventFunc);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribeFromEvent("logout-event", logoutEventFunc);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!myAddress) return; // Only proceed if myAddress is set
|
if (!myAddress) return; // Only proceed if myAddress is set
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user