resend topic on ws reconect

main
alex 2023-10-23 16:56:44 +02:00
parent 076ed7f6e7
commit b6824989c2
1 changed files with 15 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import {
hasOnePermission,
hasOneXYPermission,
hasPermission,
wsConnectionCustomEventName,
} from "../../utils";
import { useTranslation } from "react-i18next";
import { MyUserAvatar } from "../MyAvatar";
@ -296,10 +297,20 @@ export function SideMenuContent({
lastSubscribedTopic.current = pathname;
webSocketContext.SendSocketMessage(SentMessagesCommands.SubscribeToTopic, {
topic: pathname,
browserTabSession: BrowserTabSession,
});
const subscribeTopicMessage = () =>
webSocketContext.SendSocketMessage(
SentMessagesCommands.SubscribeToTopic,
{
topic: pathname,
browserTabSession: BrowserTabSession,
}
);
subscribeTopicMessage();
document.addEventListener(wsConnectionCustomEventName, () =>
subscribeTopicMessage()
);
// auto close sideMenu on mobile
// this will prevent to auto close sideMenu on first render as the useEffects will be called after the first render