mattermost-mobile/app/reducers/views/recent_emojis.js
Chris Duarte e345ee1e7b Add recently used section (#1136)
* Add recently used section and section icons

* Improve section scrolling indication

* Modify Makefile and use onMomentumScrollEnd

* Make sure top section maintains highlight when scrolled to top

* Sort emojis by startsWith then includes when filtering
2017-11-21 10:20:09 -05:00

23 lines
No EOL
569 B
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {ViewTypes} from 'app/constants';
export default function recentEmojis(state = [], action) {
switch (action.type) {
case ViewTypes.ADD_RECENT_EMOJI: {
const nextState = [...state];
const index = nextState.indexOf(action.emoji);
if (index !== -1) {
nextState.splice(index, 1);
}
nextState.unshift(action.emoji);
return nextState;
}
default:
return state;
}
}