This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #637 from LiskHQ/619-loading-bar-issues
Fix global loading bar issues - Closes #619
- Loading branch information
Showing
5 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ | |
width: 100vw; | ||
z-index: 201; | ||
} | ||
|
||
.linear { | ||
background: rgb(60, 185, 253); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import metronomeMiddleware from './metronome'; | ||
import accountMiddleware from './account'; | ||
import loginMiddleware from './login'; | ||
import loadingBarMiddleware from './loadingBar'; | ||
import offlineMiddleware from './offline'; | ||
import notificationMiddleware from './notification'; | ||
|
||
export default [ | ||
loginMiddleware, | ||
metronomeMiddleware, | ||
accountMiddleware, | ||
loadingBarMiddleware, | ||
offlineMiddleware, | ||
notificationMiddleware, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import actionsType from '../../constants/actions'; | ||
|
||
const ignoredLoadingActionKeys = ['loader/status']; | ||
|
||
const loadingBarMiddleware = () => next => (action) => { | ||
switch (action.type) { | ||
case actionsType.loadingStarted: | ||
case actionsType.loadingFinished: | ||
if (ignoredLoadingActionKeys.indexOf(action.data) === -1) { | ||
next(action); | ||
} | ||
break; | ||
default: | ||
next(action); | ||
break; | ||
} | ||
}; | ||
|
||
export default loadingBarMiddleware; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { expect } from 'chai'; | ||
import { spy, stub } from 'sinon'; | ||
import middleware from './loadingBar'; | ||
import actionType from '../../constants/actions'; | ||
|
||
|
||
describe('LoadingBar middleware', () => { | ||
let store; | ||
let next; | ||
const ignoredLoadingActionKeys = ['loader/status']; | ||
|
||
beforeEach(() => { | ||
store = stub(); | ||
store.dispatch = spy(); | ||
next = spy(); | ||
}); | ||
|
||
it('should pass the action to next middleware on some random action', () => { | ||
const randomAction = { | ||
type: 'TEST_ACTION', | ||
}; | ||
|
||
middleware(store)(next)(randomAction); | ||
expect(next).to.have.been.calledWith(randomAction); | ||
}); | ||
|
||
it(`should not call next on ${actionType.loadingStarted} action if action.data == '${ignoredLoadingActionKeys[0]}'`, () => { | ||
const action = { | ||
type: actionType.loadingStarted, | ||
data: ignoredLoadingActionKeys[0], | ||
}; | ||
|
||
middleware(store)(next)(action); | ||
expect(next).not.to.have.been.calledWith(action); | ||
}); | ||
|
||
it(`should not call next on ${actionType.loadingFinished} action if action.data == '${ignoredLoadingActionKeys[0]}'`, () => { | ||
const action = { | ||
type: actionType.loadingFinished, | ||
data: ignoredLoadingActionKeys[0], | ||
}; | ||
|
||
middleware(store)(next)(action); | ||
expect(next).not.to.have.been.calledWith(action); | ||
}); | ||
|
||
it(`should call next on ${actionType.loadingStarted} action if action.data != '${ignoredLoadingActionKeys[0]}'`, () => { | ||
const action = { | ||
type: actionType.loadingStarted, | ||
data: 'something/else', | ||
}; | ||
|
||
middleware(store)(next)(action); | ||
expect(next).to.have.been.calledWith(action); | ||
}); | ||
|
||
it(`should call next on ${actionType.loadingFinished} action if action.data != '${ignoredLoadingActionKeys[0]}'`, () => { | ||
const action = { | ||
type: actionType.loadingFinished, | ||
data: 'something/else', | ||
}; | ||
|
||
middleware(store)(next)(action); | ||
expect(next).to.have.been.calledWith(action); | ||
}); | ||
}); | ||
|