2019-02-27 01:40:01 +08:00
|
|
|
import React from 'react';
|
2024-10-03 04:10:47 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2019-02-27 01:40:01 +08:00
|
|
|
import { injectIntl } from 'react-intl';
|
2024-04-25 22:53:56 +08:00
|
|
|
import { useMutation } from '@apollo/client';
|
2019-02-27 01:40:01 +08:00
|
|
|
import ActivityCheck from './component';
|
2024-04-25 22:53:56 +08:00
|
|
|
import { USER_SEND_ACTIVITY_SIGN } from './mutations';
|
2024-08-29 21:09:53 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2019-02-27 01:40:01 +08:00
|
|
|
|
2024-10-03 04:10:47 +08:00
|
|
|
const ActivityCheckContainer = ({ intl }) => {
|
2024-04-25 22:53:56 +08:00
|
|
|
const [userActivitySign] = useMutation(USER_SEND_ACTIVITY_SIGN);
|
2024-08-29 21:09:53 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
inactivityWarningDisplay: user.inactivityWarningDisplay,
|
|
|
|
inactivityWarningTimeoutSecs: user.inactivityWarningTimeoutSecs,
|
|
|
|
}));
|
|
|
|
const inactivityWarningDisplay = currentUserData?.inactivityWarningDisplay;
|
|
|
|
const inactivityWarningTimeoutSecs = currentUserData?.inactivityWarningTimeoutSecs;
|
2024-04-25 22:53:56 +08:00
|
|
|
|
2024-08-29 21:09:53 +08:00
|
|
|
if (!inactivityWarningDisplay) return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ActivityCheck
|
|
|
|
userActivitySign={userActivitySign}
|
|
|
|
inactivityCheck={inactivityWarningDisplay}
|
|
|
|
responseDelay={inactivityWarningTimeoutSecs}
|
2024-10-03 04:10:47 +08:00
|
|
|
intl={intl}
|
2024-08-29 21:09:53 +08:00
|
|
|
/>
|
|
|
|
);
|
2024-04-25 22:53:56 +08:00
|
|
|
};
|
2024-10-03 04:10:47 +08:00
|
|
|
ActivityCheckContainer.propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
};
|
2019-02-27 01:40:01 +08:00
|
|
|
|
|
|
|
export default injectIntl(ActivityCheckContainer);
|