mattermost-mobile/service/selectors/entities/typing.js
enahum e74ecfa5f2 PLT-5510 Show user is typing (#278)
* PLT-5510 Show user is typing

* Move autocomplete below the user typing
2017-02-20 17:39:20 -03:00

31 lines
949 B
JavaScript

// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {createSelector} from 'reselect';
import {getCurrentChannelId} from './channels';
import {getMyPreferences} from './preferences';
import {getUsers} from './users';
import {displayUsername} from 'service/utils/user_utils';
export const getUsersTyping = createSelector(
getUsers,
getMyPreferences,
getCurrentChannelId,
(state) => state.entities.posts.selectedPostId,
(state) => state.entities.typing,
(profiles, preferences, channelId, parentPostId, typing) => {
const id = channelId + parentPostId;
if (typing[id]) {
const users = Object.keys(typing[id]);
if (users.length) {
return users.map((userId) => {
return displayUsername(profiles[userId], preferences);
});
}
}
return [];
}
);