refactoring
This commit is contained in:
parent
eadcb92d96
commit
755985ada7
@ -89,6 +89,8 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
|
|||||||
isFrame,
|
isFrame,
|
||||||
|
|
||||||
organizationName,
|
organizationName,
|
||||||
|
setDataFromSocket,
|
||||||
|
setCurrentDataFromSocket,
|
||||||
} = rest;
|
} = rest;
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -162,6 +164,37 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
|
|||||||
command: "subscribe",
|
command: "subscribe",
|
||||||
data: { roomParts: "QUOTA", individual: true },
|
data: { roomParts: "QUOTA", individual: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socketHelper.emit({
|
||||||
|
command: "subscribeToPortal",
|
||||||
|
});
|
||||||
|
|
||||||
|
socketHelper.emit({
|
||||||
|
command: "getSessionsInPortal",
|
||||||
|
});
|
||||||
|
|
||||||
|
socketHelper.on("statuses-in-portal", (data) => {
|
||||||
|
setDataFromSocket(data);
|
||||||
|
console.log("dataFromSocket", data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socketHelper.on("enter-in-portal", (data) => {
|
||||||
|
setCurrentDataFromSocket(data);
|
||||||
|
console.log("enter-in-portal", data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socketHelper.on("enter-session-in-portal", (data) => {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socketHelper.on("leave-in-portal", (data) => {
|
||||||
|
setCurrentDataFromSocket(data);
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socketHelper.on("leave-session-in-portal", (data) => {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
}, [socketHelper]);
|
}, [socketHelper]);
|
||||||
|
|
||||||
const { t, ready } = useTranslation(["Common"]); //TODO: if enable banner ["Common", "SmartBanner"]
|
const { t, ready } = useTranslation(["Common"]); //TODO: if enable banner ["Common", "SmartBanner"]
|
||||||
@ -455,8 +488,11 @@ const ShellWrapper = inject(
|
|||||||
userStore,
|
userStore,
|
||||||
currentTariffStatusStore,
|
currentTariffStatusStore,
|
||||||
dialogsStore,
|
dialogsStore,
|
||||||
|
peopleStore,
|
||||||
}) => {
|
}) => {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
|
const { setDataFromSocket, setCurrentDataFromSocket } =
|
||||||
|
peopleStore.selectionStore;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
init,
|
init,
|
||||||
@ -546,6 +582,8 @@ const ShellWrapper = inject(
|
|||||||
pagesWithoutNavMenu,
|
pagesWithoutNavMenu,
|
||||||
isFrame,
|
isFrame,
|
||||||
organizationName,
|
organizationName,
|
||||||
|
setDataFromSocket,
|
||||||
|
setCurrentDataFromSocket,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
)(observer(Shell));
|
)(observer(Shell));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { withTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { observer, inject } from "mobx-react";
|
import { observer, inject } from "mobx-react";
|
||||||
import styled, { css } from "styled-components";
|
import styled, { css } from "styled-components";
|
||||||
|
|
||||||
@ -44,7 +44,8 @@ const StyledScrollbar = styled(Scrollbar)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const UserSessionsPanel = (props) => {
|
const UserSessionsPanel = (props) => {
|
||||||
const { t, visible, setVisible } = props;
|
const { visible, setVisible } = props;
|
||||||
|
const { t } = useTranslation(["Settings", "Profile", "Common"]);
|
||||||
const scrollRef = useRef(null);
|
const scrollRef = useRef(null);
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
@ -86,8 +87,4 @@ export default inject(({ dialogsStore }) => {
|
|||||||
visible: userSessionsPanelVisible,
|
visible: userSessionsPanelVisible,
|
||||||
setVisible: setUserSessionPanelVisible,
|
setVisible: setUserSessionPanelVisible,
|
||||||
};
|
};
|
||||||
})(
|
})(observer(UserSessionsPanel));
|
||||||
withTranslation(["Settings", "Profile", "Common"])(
|
|
||||||
observer(UserSessionsPanel),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { withTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import { mobile, tablet } from "@docspace/shared/utils";
|
import { mobile, tablet } from "@docspace/shared/utils";
|
||||||
import SessionsLoader from "@docspace/shared/skeletons/sessions";
|
import SessionsLoader from "@docspace/shared/skeletons/sessions";
|
||||||
@ -75,13 +75,12 @@ const DownLoadWrapper = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const Sessions = ({
|
const Sessions = ({
|
||||||
t,
|
|
||||||
allSessions,
|
allSessions,
|
||||||
sessionsData,
|
sessionsData,
|
||||||
dataFromSocket,
|
dataFromSocket,
|
||||||
|
currentDataFromSocket,
|
||||||
displayName,
|
displayName,
|
||||||
clearSelection,
|
clearSelection,
|
||||||
setDataFromSocket,
|
|
||||||
updateAllSessions,
|
updateAllSessions,
|
||||||
platformData,
|
platformData,
|
||||||
selection,
|
selection,
|
||||||
@ -90,7 +89,6 @@ const Sessions = ({
|
|||||||
isLoading,
|
isLoading,
|
||||||
viewAs,
|
viewAs,
|
||||||
setViewAs,
|
setViewAs,
|
||||||
socketHelper,
|
|
||||||
currentDeviceType,
|
currentDeviceType,
|
||||||
disableDialogVisible,
|
disableDialogVisible,
|
||||||
logoutDialogVisible,
|
logoutDialogVisible,
|
||||||
@ -107,20 +105,13 @@ const Sessions = ({
|
|||||||
isLoadingDownloadReport,
|
isLoadingDownloadReport,
|
||||||
isSessionsLoaded,
|
isSessionsLoaded,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation([
|
||||||
|
"Settings",
|
||||||
|
"Profile",
|
||||||
|
"Common",
|
||||||
|
"ChangeUserStatusDialog",
|
||||||
|
]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
socketHelper.emit({
|
|
||||||
command: "subscribe",
|
|
||||||
data: { roomParts: "statuses-in-portal" },
|
|
||||||
});
|
|
||||||
|
|
||||||
socketHelper.emit({
|
|
||||||
command: "getSessionsInPortal",
|
|
||||||
});
|
|
||||||
|
|
||||||
socketHelper.on("statuses-in-portal", (data) => {
|
|
||||||
setDataFromSocket(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchData();
|
fetchData();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@ -129,8 +120,8 @@ const Sessions = ({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateAllSessions(sessionsData, dataFromSocket);
|
updateAllSessions(sessionsData, dataFromSocket, currentDataFromSocket);
|
||||||
}, [sessionsData, dataFromSocket]);
|
}, [sessionsData, dataFromSocket, currentDataFromSocket]);
|
||||||
|
|
||||||
useViewEffect({
|
useViewEffect({
|
||||||
view: viewAs,
|
view: viewAs,
|
||||||
@ -227,14 +218,14 @@ const Sessions = ({
|
|||||||
|
|
||||||
export default inject(({ settingsStore, setup, peopleStore }) => {
|
export default inject(({ settingsStore, setup, peopleStore }) => {
|
||||||
const { updateUserStatus } = peopleStore.usersStore;
|
const { updateUserStatus } = peopleStore.usersStore;
|
||||||
const { socketHelper, currentDeviceType } = settingsStore;
|
const { currentDeviceType } = settingsStore;
|
||||||
const {
|
const {
|
||||||
allSessions,
|
allSessions,
|
||||||
sessionsData,
|
sessionsData,
|
||||||
dataFromSocket,
|
dataFromSocket,
|
||||||
|
currentDataFromSocket,
|
||||||
displayName,
|
displayName,
|
||||||
clearSelection,
|
clearSelection,
|
||||||
setDataFromSocket,
|
|
||||||
updateAllSessions,
|
updateAllSessions,
|
||||||
platformData,
|
platformData,
|
||||||
fetchData,
|
fetchData,
|
||||||
@ -264,9 +255,9 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
|
|||||||
allSessions,
|
allSessions,
|
||||||
sessionsData,
|
sessionsData,
|
||||||
dataFromSocket,
|
dataFromSocket,
|
||||||
|
currentDataFromSocket,
|
||||||
displayName,
|
displayName,
|
||||||
clearSelection,
|
clearSelection,
|
||||||
setDataFromSocket,
|
|
||||||
updateAllSessions,
|
updateAllSessions,
|
||||||
platformData,
|
platformData,
|
||||||
selection,
|
selection,
|
||||||
@ -274,7 +265,6 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
|
|||||||
fetchData,
|
fetchData,
|
||||||
viewAs,
|
viewAs,
|
||||||
setViewAs,
|
setViewAs,
|
||||||
socketHelper,
|
|
||||||
currentDeviceType,
|
currentDeviceType,
|
||||||
disableDialogVisible,
|
disableDialogVisible,
|
||||||
logoutDialogVisible,
|
logoutDialogVisible,
|
||||||
@ -292,8 +282,4 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
|
|||||||
isLoadingDownloadReport,
|
isLoadingDownloadReport,
|
||||||
isSessionsLoaded: allSessions.length > 0,
|
isSessionsLoaded: allSessions.length > 0,
|
||||||
};
|
};
|
||||||
})(
|
})(observer(Sessions));
|
||||||
withTranslation(["Settings", "Profile", "Common", "ChangeUserStatusDialog"])(
|
|
||||||
observer(Sessions),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user