From 7eeb63cb3f887770b68c36cd56e60ba390eea128 Mon Sep 17 00:00:00 2001 From: picklesrus Date: Thu, 16 Jul 2020 12:24:13 -0400 Subject: [PATCH] rename SetupMessagePolling to pollForMessages --- src/components/navigation/www/navigation.jsx | 10 +++++----- test/unit/components/navigation.test.jsx | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/navigation/www/navigation.jsx b/src/components/navigation/www/navigation.jsx index 9ed2e3cb4..3346aeb79 100644 --- a/src/components/navigation/www/navigation.jsx +++ b/src/components/navigation/www/navigation.jsx @@ -28,7 +28,7 @@ class Navigation extends React.Component { bindAll(this, [ 'getProfileUrl', 'handleSearchSubmit', - 'setupMessagePolling' + 'pollForMessages' ]); this.state = { messageCountIntervalId: -1 // javascript method interval id for getting messsage count. @@ -37,14 +37,14 @@ class Navigation extends React.Component { componentDidMount () { if (this.props.user) { // Setup polling for messages to start in 2 minutes. - setTimeout(this.setupMessagePolling.bind(this, 2), 2 * 60 * 1000); + setTimeout(this.pollForMessages.bind(this, 2), 2 * 60 * 1000); } } componentDidUpdate (prevProps) { if (prevProps.user !== this.props.user) { this.props.handleCloseAccountNav(); if (this.props.user) { - setTimeout(this.setupMessagePolling.bind(this, 2), 2 * 60 * 1000); + setTimeout(this.pollForMessages.bind(this, 2), 2 * 60 * 1000); } else { // clear message count check, and set to default id. clearTimeout(this.state.messageCountIntervalId); @@ -70,7 +70,7 @@ class Navigation extends React.Component { return `/users/${this.props.user.username}/`; } - setupMessagePolling (minutes) { + pollForMessages (minutes) { this.props.getMessageCount(this.props.user.username); // We only poll if it has been less than 30 minutes. // Chances of someone actively using the page for that long without @@ -78,7 +78,7 @@ class Navigation extends React.Component { if (minutes < 32) { const nextFetch = minutes * 2; const timeoutId = setTimeout(() => { - this.setupMessagePolling(nextFetch); + this.pollForMessages(nextFetch); }, nextFetch * 60000); this.setState({ // eslint-disable-line react/no-did-mount-set-state messageCountIntervalId: timeoutId diff --git a/test/unit/components/navigation.test.jsx b/test/unit/components/navigation.test.jsx index e74bf125b..2333bc509 100644 --- a/test/unit/components/navigation.test.jsx +++ b/test/unit/components/navigation.test.jsx @@ -138,7 +138,7 @@ describe('Navigation', () => { expect(props.getMessageCount).toHaveBeenCalled(); }); - test('SetupMessagePolling polls for messages 5 times', () => { + test('pollForMessages polls for messages 5 times', () => { store = mockStore({ navigation: { registrationOpen: false @@ -164,11 +164,11 @@ describe('Navigation', () => { const navInstance = intlWrapper.children().find('Navigation') .instance(); // Clear the timers and mocks because componentDidMount - // has already called setupMessagePolling. + // has already called pollForMessages. jest.clearAllTimers(); jest.clearAllMocks(); - navInstance.setupMessagePolling(2); + navInstance.pollForMessages(2); // Check that we set the timeout to backoff exponentially let minutes = 2 * 60 * 1000; @@ -185,7 +185,7 @@ describe('Navigation', () => { // and stop after 32 minutes so it should happen 5 times total. expect(props.getMessageCount).toHaveBeenCalledTimes(5); // setTimeout happens 1 fewer since the original call to - // setupMessagePolling isn't counted here. + // pollForMessages isn't counted here. expect(setTimeout).toHaveBeenCalledTimes(4); }); });