mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-02-11 17:55:49 +00:00
logout event
This commit is contained in:
parent
7f050554a8
commit
603afcb8b6
@ -1019,8 +1019,8 @@ function App() {
|
||||
}
|
||||
chrome?.runtime?.sendMessage({ action: "logout" }, (response) => {
|
||||
if (response) {
|
||||
resetAllStates();
|
||||
executeEvent("logout-event", {});
|
||||
resetAllStates();
|
||||
}
|
||||
});
|
||||
} catch (error) {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { getBaseApiReactSocket, pauseAllQueues, resumeAllQueues } from '../../App';
|
||||
import { subscribeToEvent, unsubscribeFromEvent } from '../../utils/events';
|
||||
|
||||
export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
||||
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(() => {
|
||||
if (!myAddress) return; // Only proceed if myAddress is set
|
||||
if (!window?.location?.href?.includes("?main=true")) return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user