diff --git a/src/components/views/settings/devices/SecurityRecommendations.tsx b/src/components/views/settings/devices/SecurityRecommendations.tsx index 82eb49fd47..3132eba38a 100644 --- a/src/components/views/settings/devices/SecurityRecommendations.tsx +++ b/src/components/views/settings/devices/SecurityRecommendations.tsx @@ -29,11 +29,13 @@ import { interface Props { devices: DevicesDictionary; + currentDeviceId: DeviceWithVerification['device_id']; goToFilteredList: (filter: DeviceSecurityVariation) => void; } const SecurityRecommendations: React.FC = ({ devices, + currentDeviceId, goToFilteredList, }) => { const devicesArray = Object.values(devices); @@ -41,7 +43,12 @@ const SecurityRecommendations: React.FC = ({ const unverifiedDevicesCount = filterDevicesBySecurityRecommendation( devicesArray, [DeviceSecurityVariation.Unverified], - ).length; + ) + // filter out the current device + // as unverfied warning and actions + // will be shown in current session section + .filter((device) => device.device_id !== currentDeviceId) + .length; const inactiveDevicesCount = filterDevicesBySecurityRecommendation( devicesArray, [DeviceSecurityVariation.Inactive], diff --git a/src/components/views/settings/tabs/user/SessionManagerTab.tsx b/src/components/views/settings/tabs/user/SessionManagerTab.tsx index 607549ec4d..07f60e2725 100644 --- a/src/components/views/settings/tabs/user/SessionManagerTab.tsx +++ b/src/components/views/settings/tabs/user/SessionManagerTab.tsx @@ -62,7 +62,11 @@ const SessionManagerTab: React.FC = () => { }, [scrollIntoViewTimeoutRef]); return - + ', () => { const defaultProps = { devices: {}, goToFilteredList: jest.fn(), + currentDeviceId: 'abc123', }; const getComponent = (props = {}) => (); @@ -53,6 +54,16 @@ describe('', () => { expect(container).toMatchSnapshot(); }); + it('does not render unverified devices section when only the current device is unverified', () => { + const devices = { + [unverifiedNoMetadata.device_id]: unverifiedNoMetadata, + [verifiedNoMetadata.device_id]: verifiedNoMetadata, + }; + const { container } = render(getComponent({ devices, currentDeviceId: unverifiedNoMetadata.device_id })); + // nothing to render + expect(container.firstChild).toBeFalsy(); + }); + it('renders inactive devices section when user has inactive devices', () => { const devices = { [verifiedNoMetadata.device_id]: verifiedNoMetadata,