forked from mattermost/mattermost-redux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-14456 Minor updates to search (mattermost#812)
* Add getCurrentSearchForCurrentTeam selector * Set isEnd for search if returned less posts than asked for
- Loading branch information
Showing
4 changed files
with
46 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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {createSelector} from 'reselect'; | ||
|
||
import {getCurrentTeamId} from 'selectors/entities/teams'; | ||
|
||
export const getCurrentSearchForCurrentTeam = createSelector( | ||
(state) => state.entities.search.current, | ||
getCurrentTeamId, | ||
(current, teamId) => { | ||
return current[teamId]; | ||
} | ||
); |
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,29 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import assert from 'assert'; | ||
|
||
import deepFreezeAndThrowOnMutation from 'utils/deep_freeze'; | ||
import TestHelper from 'test/test_helper'; | ||
import * as Selectors from 'selectors/entities/search'; | ||
|
||
describe('Selectors.Search', () => { | ||
const team1 = TestHelper.fakeTeamWithId(); | ||
|
||
const team1CurrentSearch = {params: {page: 0, per_page: 20}, isEnd: true}; | ||
|
||
const testState = deepFreezeAndThrowOnMutation({ | ||
entities: { | ||
teams: { | ||
currentTeamId: team1.id, | ||
}, | ||
search: { | ||
current: {[team1.id]: team1CurrentSearch}, | ||
}, | ||
}, | ||
}); | ||
|
||
it('should return current search for current team', () => { | ||
assert.deepEqual(Selectors.getCurrentSearchForCurrentTeam(testState), team1CurrentSearch); | ||
}); | ||
}); |