diff --git a/app/components/channel_icon.js b/app/components/channel_icon.js index f865d83e4..558a62563 100644 --- a/app/components/channel_icon.js +++ b/app/components/channel_icon.js @@ -19,6 +19,7 @@ export default class ChannelIcon extends React.PureComponent { isActive: PropTypes.bool, isInfo: PropTypes.bool, isUnread: PropTypes.bool, + hasDraft: PropTypes.bool, membersCount: PropTypes.number, size: PropTypes.number, status: PropTypes.string, @@ -40,6 +41,7 @@ export default class ChannelIcon extends React.PureComponent { isActive, isUnread, isInfo, + hasDraft, membersCount, size, status, @@ -85,6 +87,13 @@ export default class ChannelIcon extends React.PureComponent { style={[style.icon, unreadIcon, activeIcon, {fontSize: size}]} /> ); + } else if (hasDraft) { + icon = ( + + ); } else if (type === General.OPEN_CHANNEL) { icon = ( + + + + +`; + +exports[`ChannelItem should match snapshot with draft 1`] = ` + + + + + + { isChannelMuted: false, isMyUser: true, isUnread: true, + hasDraft: false, mentions: 0, navigator: {push: () => {}}, // eslint-disable-line no-empty-function onSelectChannel: () => {}, // eslint-disable-line no-empty-function @@ -25,12 +28,7 @@ describe('ChannelItem', () => { status: 'online', teammateDeletedAt: 0, type: 'O', - theme: { - sidebarText: '#aaa', - sidebarTextActiveBorder: '#aaa', - sidebarTextActiveColor: '#aaa', - sidebarTextHoverBg: '#aaa', - }, + theme: Preferences.THEMES.default, unreadMsgs: 1, isArchived: false, }; @@ -56,4 +54,16 @@ describe('ChannelItem', () => { ); expect(wrapper.getElement()).toMatchSnapshot(); }); + + test('should match snapshot with draft', () => { + const wrapper = shallow( + , + {context: {intl: {formatMessage: jest.fn()}}}, + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); }); diff --git a/app/components/sidebars/main/channels_list/channel_item/index.js b/app/components/sidebars/main/channels_list/channel_item/index.js index de62b95d8..074eee573 100644 --- a/app/components/sidebars/main/channels_list/channel_item/index.js +++ b/app/components/sidebars/main/channels_list/channel_item/index.js @@ -15,6 +15,8 @@ import {getCurrentUserId, getUser} from 'mattermost-redux/selectors/entities/use import {isChannelMuted} from 'mattermost-redux/utils/channel_utils'; import {displayUsername} from 'mattermost-redux/utils/user_utils'; +import {getDraftForChannel} from 'app/selectors/views'; + import ChannelItem from './channel_item'; function makeMapStateToProps() { @@ -22,8 +24,9 @@ function makeMapStateToProps() { return (state, ownProps) => { const channel = ownProps.channel || getChannel(state, {id: ownProps.channelId}); - const member = getMyChannelMember(state, ownProps.channelId); + const member = getMyChannelMember(state, channel.id); const currentUserId = getCurrentUserId(state); + const channelDraft = getDraftForChannel(state, channel.id); let isMyUser = false; let teammateDeletedAt = 0; @@ -75,6 +78,7 @@ function makeMapStateToProps() { fake: channel.fake, isChannelMuted: isChannelMuted(member), isMyUser, + hasDraft: Boolean(channelDraft.draft || channelDraft.files.length), mentions: member ? member.mention_count : 0, shouldHideChannel, showUnreadForMsgs, diff --git a/app/selectors/views.js b/app/selectors/views.js index b6d0c63d0..81c68a185 100644 --- a/app/selectors/views.js +++ b/app/selectors/views.js @@ -26,6 +26,11 @@ export const getCurrentChannelDraft = createSelector( } ); +export function getDraftForChannel(state, channelId) { + const drafts = getChannelDrafts(state); + return drafts[channelId] || emptyDraft; +} + export const getThreadDraft = createSelector( getThreadDrafts, (state, rootId) => rootId,