diff --git a/src/lib/session.js b/src/lib/session.js index 8094ab3f1..22490a010 100644 --- a/src/lib/session.js +++ b/src/lib/session.js @@ -64,6 +64,6 @@ module.exports.requestSessionWithRetry = (resolve, reject, retriesLeft, totalDel }); }; -module.exports.requestSessionOnce = (resolve, reject) => ( +module.exports.requestSession = (resolve, reject) => ( module.exports.requestSessionWithRetry(resolve, reject, 0, 0) ); diff --git a/src/redux/session.js b/src/redux/session.js index c2dffa1da..a0d951a07 100644 --- a/src/redux/session.js +++ b/src/redux/session.js @@ -1,7 +1,7 @@ const keyMirror = require('keymirror'); const defaults = require('lodash.defaults'); -const sessionLib = require('../lib/session'); +const {requestSession, requestSessionWithRetry} = require('../lib/session'); const messageCountActions = require('./message-count.js'); const permissionsActions = require('./permissions.js'); @@ -100,7 +100,7 @@ const handleSessionResponse = (dispatch, body) => { module.exports.refreshSession = () => (dispatch => { dispatch(module.exports.setStatus(module.exports.Status.FETCHING)); return new Promise((resolve, reject) => ( - sessionLib.requestSessionOnce(resolve, reject).then(body => { + requestSession(resolve, reject).then(body => { handleSessionResponse(dispatch, body); }, err => { dispatch(module.exports.setSessionError(err)); @@ -111,7 +111,7 @@ module.exports.refreshSession = () => (dispatch => { module.exports.refreshSessionWithRetry = () => (dispatch => { dispatch(module.exports.setStatus(module.exports.Status.FETCHING)); return new Promise((resolve, reject) => ( - sessionLib.requestSessionWithRetry(4, resolve, reject) + requestSessionWithRetry(resolve, reject, 4, 7500) )).then(body => { handleSessionResponse(dispatch, body); }, err => { diff --git a/test/unit/lib/session.test.js b/test/unit/lib/session.test.js index 3b1bbe7a2..324cf6f1f 100644 --- a/test/unit/lib/session.test.js +++ b/test/unit/lib/session.test.js @@ -43,10 +43,10 @@ describe('session library', () => { jest.clearAllMocks(); }); - test('requestSessionOnce can call api 1 time, when session found', done => { + test('requestSession can call api 1 time, when session found', done => { whichMockAPIRequest = sessionYesUser; new Promise((resolve, reject) => { // eslint-disable-line no-undef - sessionLib.requestSessionOnce(resolve, reject); + sessionLib.requestSession(resolve, reject); }).then(body => { expect(sessionYesUser).toHaveBeenCalledTimes(1); expect(body).toEqual({user: {username: 'test_username'}}); @@ -54,10 +54,10 @@ describe('session library', () => { }); }); - test('requestSessionOnce can call api 1 time, when session not found', done => { + test('requestSession can call api 1 time, when session not found', done => { whichMockAPIRequest = sessionNoUser; new Promise((resolve, reject) => { // eslint-disable-line no-undef - sessionLib.requestSessionOnce(resolve, reject); + sessionLib.requestSession(resolve, reject); }).then(body => { expect(sessionNoUser).toHaveBeenCalledTimes(1); expect(body).toEqual({});