2024-04-03 21:01:08 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { CONNECTION_STATUS_REPORT_SUBSCRIPTION } from '../queries';
|
2024-09-13 21:15:35 +08:00
|
|
|
import {
|
|
|
|
sortConnectionData,
|
|
|
|
startMonitoringNetwork,
|
|
|
|
stopMonitoringNetwork,
|
|
|
|
} from '../service';
|
2024-04-03 21:01:08 +08:00
|
|
|
import Component from './component';
|
2024-04-04 21:41:01 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-06-04 21:40:54 +08:00
|
|
|
import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription';
|
2024-07-05 04:26:09 +08:00
|
|
|
import { useReactiveVar } from '@apollo/client';
|
|
|
|
import connectionStatus from '/imports/ui/core/graphql/singletons/connectionStatus';
|
2024-04-03 21:01:08 +08:00
|
|
|
|
|
|
|
const ConnectionStatusContainer = (props) => {
|
2024-06-04 21:40:54 +08:00
|
|
|
const { data } = useDeduplicatedSubscription(CONNECTION_STATUS_REPORT_SUBSCRIPTION);
|
2024-09-13 21:15:35 +08:00
|
|
|
const connectionData = data ? sortConnectionData(data.user_connectionStatusReport) : [];
|
2024-04-04 21:41:01 +08:00
|
|
|
const { data: currentUser } = useCurrentUser((u) => ({ isModerator: u.isModerator }));
|
|
|
|
const amIModerator = !!currentUser?.isModerator;
|
2024-07-05 04:26:09 +08:00
|
|
|
|
2024-09-13 21:15:35 +08:00
|
|
|
const networkData = useReactiveVar(connectionStatus.getNetworkDataVar());
|
2024-07-05 04:26:09 +08:00
|
|
|
|
2024-04-03 21:01:08 +08:00
|
|
|
return (
|
|
|
|
<Component
|
2024-07-05 04:26:09 +08:00
|
|
|
{...props}
|
2024-04-03 21:01:08 +08:00
|
|
|
connectionData={connectionData}
|
2024-04-04 21:41:01 +08:00
|
|
|
amIModerator={amIModerator}
|
2024-09-13 21:15:35 +08:00
|
|
|
networkData={networkData}
|
|
|
|
startMonitoringNetwork={startMonitoringNetwork}
|
|
|
|
stopMonitoringNetwork={stopMonitoringNetwork}
|
2024-04-03 21:01:08 +08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ConnectionStatusContainer;
|