From 0f62befef06f7fc467571a87affdfa95fa1fbb81 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Sat, 24 Oct 2015 15:50:20 +0200 Subject: code style theme chooser --- .../user_settings/code_theme_chooser.jsx | 55 ++++++++++++++++++++++ .../user_settings/user_settings_appearance.jsx | 23 ++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 web/react/components/user_settings/code_theme_chooser.jsx (limited to 'web/react/components') diff --git a/web/react/components/user_settings/code_theme_chooser.jsx b/web/react/components/user_settings/code_theme_chooser.jsx new file mode 100644 index 000000000..eef4b24ba --- /dev/null +++ b/web/react/components/user_settings/code_theme_chooser.jsx @@ -0,0 +1,55 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +var Constants = require('../../utils/constants.jsx'); + +export default class CodeThemeChooser extends React.Component { + constructor(props) { + super(props); + this.state = {}; + } + render() { + const theme = this.props.theme; + + const premadeThemes = []; + for (const k in Constants.CODE_THEMES) { + if (Constants.CODE_THEMES.hasOwnProperty(k)) { + let activeClass = ''; + if (k === theme.codeTheme) { + activeClass = 'active'; + } + + premadeThemes.push( +
+
this.props.updateTheme(k)} + > + +
+
+ ); + } + } + + return ( +
+ {premadeThemes} +
+ ); + } +} + +CodeThemeChooser.propTypes = { + theme: React.PropTypes.object.isRequired, + updateTheme: React.PropTypes.func.isRequired +}; diff --git a/web/react/components/user_settings/user_settings_appearance.jsx b/web/react/components/user_settings/user_settings_appearance.jsx index 8c62a189d..e94894a1d 100644 --- a/web/react/components/user_settings/user_settings_appearance.jsx +++ b/web/react/components/user_settings/user_settings_appearance.jsx @@ -7,6 +7,7 @@ var Utils = require('../../utils/utils.jsx'); const CustomThemeChooser = require('./custom_theme_chooser.jsx'); const PremadeThemeChooser = require('./premade_theme_chooser.jsx'); +const CodeThemeChooser = require('./code_theme_chooser.jsx'); const AppDispatcher = require('../../dispatcher/app_dispatcher.jsx'); const Constants = require('../../utils/constants.jsx'); const ActionTypes = Constants.ActionTypes; @@ -18,12 +19,14 @@ export default class UserSettingsAppearance extends React.Component { this.onChange = this.onChange.bind(this); this.submitTheme = this.submitTheme.bind(this); this.updateTheme = this.updateTheme.bind(this); + this.updateCodeTheme = this.updateCodeTheme.bind(this); this.handleClose = this.handleClose.bind(this); this.handleImportModal = this.handleImportModal.bind(this); this.state = this.getStateFromStores(); this.originalTheme = this.state.theme; + this.originalCodeTheme = this.state.theme.codeTheme; } componentDidMount() { UserStore.addChangeListener(this.onChange); @@ -58,6 +61,10 @@ export default class UserSettingsAppearance extends React.Component { type = 'custom'; } + if (!theme.codeTheme) { + theme.codeTheme = Constants.DEFAULT_CODE_THEME; + } + return {theme, type}; } onChange() { @@ -93,6 +100,13 @@ export default class UserSettingsAppearance extends React.Component { ); } updateTheme(theme) { + theme.codeTheme = this.state.theme.codeTheme; + this.setState({theme}); + Utils.applyTheme(theme); + } + updateCodeTheme(codeTheme) { + var theme = this.state.theme; + theme.codeTheme = codeTheme; this.setState({theme}); Utils.applyTheme(theme); } @@ -102,6 +116,7 @@ export default class UserSettingsAppearance extends React.Component { handleClose() { const state = this.getStateFromStores(); state.serverError = null; + state.theme.codeTheme = this.originalCodeTheme; Utils.applyTheme(state.theme); @@ -170,7 +185,13 @@ export default class UserSettingsAppearance extends React.Component { {custom}
- {serverError} + {'Code Theme'} + +
+ {serverError} Date: Sun, 25 Oct 2015 23:55:50 +0100 Subject: Mattermost can not send message start with slash resolves #827 --- web/react/components/create_post.jsx | 115 +++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 51 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index 8b5fc4162..055be112d 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -38,6 +38,7 @@ export default class CreatePost extends React.Component { this.getFileCount = this.getFileCount.bind(this); this.handleArrowUp = this.handleArrowUp.bind(this); this.handleResize = this.handleResize.bind(this); + this.sendMessage = this.sendMessage.bind(this); PostStore.clearDraftUploads(); @@ -122,6 +123,11 @@ export default class CreatePost extends React.Component { post.message, false, (data) => { + if (data.response === 'not implemented') { + this.sendMessage(post); + return; + } + PostStore.storeDraft(data.channel_id, null); this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null}); @@ -130,63 +136,70 @@ export default class CreatePost extends React.Component { } }, (err) => { - const state = {}; - state.serverError = err.message; - state.submitting = false; - this.setState(state); - } - ); - } else { - post.channel_id = this.state.channelId; - post.filenames = this.state.previews; - - const time = Utils.getTimestamp(); - const userId = UserStore.getCurrentId(); - post.pending_post_id = `${userId}:${time}`; - post.user_id = userId; - post.create_at = time; - post.root_id = this.state.rootId; - post.parent_id = this.state.parentId; - - const channel = ChannelStore.get(this.state.channelId); - - PostStore.storePendingPost(post); - PostStore.storeDraft(channel.id, null); - this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null}); - - Client.createPost(post, channel, - (data) => { - AsyncClient.getPosts(); - - const member = ChannelStore.getMember(channel.id); - member.msg_count = channel.total_msg_count; - member.last_viewed_at = Date.now(); - ChannelStore.setChannelMember(member); - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECIEVED_POST, - post: data - }); - }, - (err) => { - const state = {}; - - if (err.message === 'Invalid RootId parameter') { - if ($('#post_deleted').length > 0) { - $('#post_deleted').modal('show'); - } - PostStore.removePendingPost(post.pending_post_id); + if (err.sendMessage) { + this.sendMessage(post); } else { - post.state = Constants.POST_FAILED; - PostStore.updatePendingPost(post); + const state = {}; + state.serverError = err.message; + state.submitting = false; + this.setState(state); } - - state.submitting = false; - this.setState(state); } ); + } else { + this.sendMessage(post); } } + sendMessage(post) { + post.channel_id = this.state.channelId; + post.filenames = this.state.previews; + + const time = Utils.getTimestamp(); + const userId = UserStore.getCurrentId(); + post.pending_post_id = `${userId}:${time}`; + post.user_id = userId; + post.create_at = time; + post.root_id = this.state.rootId; + post.parent_id = this.state.parentId; + + const channel = ChannelStore.get(this.state.channelId); + + PostStore.storePendingPost(post); + PostStore.storeDraft(channel.id, null); + this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null}); + + Client.createPost(post, channel, + (data) => { + AsyncClient.getPosts(); + + const member = ChannelStore.getMember(channel.id); + member.msg_count = channel.total_msg_count; + member.last_viewed_at = Date.now(); + ChannelStore.setChannelMember(member); + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECIEVED_POST, + post: data + }); + }, + (err) => { + const state = {}; + + if (err.message === 'Invalid RootId parameter') { + if ($('#post_deleted').length > 0) { + $('#post_deleted').modal('show'); + } + PostStore.removePendingPost(post.pending_post_id); + } else { + post.state = Constants.POST_FAILED; + PostStore.updatePendingPost(post); + } + + state.submitting = false; + this.setState(state); + } + ); + } postMsgKeyPress(e) { if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) { e.preventDefault(); -- cgit v1.2.3-1-g7c22 From 4cfde35256cecab12d317e0d829769143f4df2d0 Mon Sep 17 00:00:00 2001 From: Girish S Date: Mon, 26 Oct 2015 12:25:14 +0530 Subject: append * to search query if not present and highlight partial matches --- web/react/components/search_bar.jsx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'web/react/components') diff --git a/web/react/components/search_bar.jsx b/web/react/components/search_bar.jsx index e1d36ad7d..fae26f803 100644 --- a/web/react/components/search_bar.jsx +++ b/web/react/components/search_bar.jsx @@ -105,6 +105,10 @@ export default class SearchBar extends React.Component { performSearch(terms, isMentionSearch) { if (terms.length) { this.setState({isSearching: true}); + + if(terms.search(/\*\s*$/) == -1) // append * if not present + terms = terms + "*"; + client.search( terms, (data) => { -- cgit v1.2.3-1-g7c22 From e9812655f6cb7e9e6c06bc1b2a462efc106f52f7 Mon Sep 17 00:00:00 2001 From: Girish S Date: Mon, 26 Oct 2015 13:00:26 +0530 Subject: made eslint happy --- web/react/components/search_bar.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/search_bar.jsx b/web/react/components/search_bar.jsx index fae26f803..0da43e8cd 100644 --- a/web/react/components/search_bar.jsx +++ b/web/react/components/search_bar.jsx @@ -106,11 +106,14 @@ export default class SearchBar extends React.Component { if (terms.length) { this.setState({isSearching: true}); - if(terms.search(/\*\s*$/) == -1) // append * if not present - terms = terms + "*"; + // append * if not present + let searchTerms = terms; + if (searchTerms.search(/\*\s*$/) === -1) { + searchTerms = searchTerms + '*'; + } client.search( - terms, + searchTerms, (data) => { this.setState({isSearching: false}); if (utils.isMobile()) { -- cgit v1.2.3-1-g7c22 From 46042d995bc553a10513c527aba106e1b92d04d4 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Sun, 25 Oct 2015 02:00:55 +0100 Subject: PLT-703: Support multiple users being shown as typing underneath input boxes. --- web/react/components/create_post.jsx | 2 +- web/react/components/msg_typing.jsx | 49 ++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 17 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index 055be112d..b74f1871c 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -208,7 +208,7 @@ export default class CreatePost extends React.Component { } const t = Date.now(); - if ((t - this.lastTime) > 5000) { + if ((t - this.lastTime) > Constants.UPDATE_TYPING_MS) { SocketStore.sendMessage({channel_id: this.state.channelId, action: 'typing', props: {parent_id: ''}, state: {}}); this.lastTime = t; } diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 1bd23c55c..42ae4bcc4 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -11,11 +11,11 @@ export default class MsgTyping extends React.Component { constructor(props) { super(props); - this.timer = null; - this.lastTime = 0; - this.onChange = this.onChange.bind(this); + this.getTypingText = this.getTypingText.bind(this); + this.componentWillReceiveProps = this.componentWillReceiveProps.bind(this); + this.typingUsers = {}; this.state = { text: '' }; @@ -27,7 +27,7 @@ export default class MsgTyping extends React.Component { componentWillReceiveProps(newProps) { if (this.props.channelId !== newProps.channelId) { - this.setState({text: ''}); + this.setState({text: this.getTypingText()}); } } @@ -36,27 +36,44 @@ export default class MsgTyping extends React.Component { } onChange(msg) { + let username = 'Someone'; if (msg.action === SocketEvents.TYPING && this.props.channelId === msg.channel_id && this.props.parentId === msg.props.parent_id) { - this.lastTime = new Date().getTime(); - - var username = 'Someone'; if (UserStore.hasProfile(msg.user_id)) { username = UserStore.getProfile(msg.user_id).username; } - this.setState({text: username + ' is typing...'}); - - if (!this.timer) { - this.timer = setInterval(function myTimer() { - if ((new Date().getTime() - this.lastTime) > 8000) { - this.setState({text: ''}); - } - }.bind(this), 3000); + if (this.typingUsers[username]) { + clearTimeout(this.typingUsers[username]); } + + this.typingUsers[username] = setTimeout(function myTimer(user) { + delete this.typingUsers[user]; + this.setState({text: this.getTypingText()}); + }.bind(this, username), Constants.UPDATE_TYPING_MS); + + this.setState({text: this.getTypingText()}); } else if (msg.action === SocketEvents.POSTED && msg.channel_id === this.props.channelId) { - this.setState({text: ''}); + if (UserStore.hasProfile(msg.user_id)) { + username = UserStore.getProfile(msg.user_id).username; + } + clearTimeout(this.typingUsers[username]); + delete this.typingUsers[username]; + this.setState({text: this.getTypingText()}); + } + } + + getTypingText() { + let users = Object.keys(this.typingUsers); + switch (users.length) { + case 0: + return ''; + case 1: + return users[0] + ' is typing...'; + default: + const last = users.pop(); + return users.join(', ') + ' and ' + last + ' are typing...'; } } -- cgit v1.2.3-1-g7c22 From b7aa4220d575d446830a0b0c9a3f753214272422 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Mon, 26 Oct 2015 02:24:46 +0100 Subject: use constant value to check if to send a typing event for comments --- web/react/components/create_comment.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react/components') diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 435c7d542..18936e808 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -147,7 +147,7 @@ export default class CreateComment extends React.Component { } const t = Date.now(); - if ((t - this.lastTime) > 5000) { + if ((t - this.lastTime) > Constants.UPDATE_TYPING_MS) { SocketStore.sendMessage({channel_id: this.props.channelId, action: 'typing', props: {parent_id: this.props.rootId}}); this.lastTime = t; } -- cgit v1.2.3-1-g7c22 From 9a4d648c9b9a6c78cd2a171b665bc5aa9ade3634 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Mon, 26 Oct 2015 17:44:29 +0100 Subject: rename getTypingText to updateTypingText and set component's state in it --- web/react/components/msg_typing.jsx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 42ae4bcc4..ccf8a2445 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -12,7 +12,7 @@ export default class MsgTyping extends React.Component { super(props); this.onChange = this.onChange.bind(this); - this.getTypingText = this.getTypingText.bind(this); + this.updateTypingText = this.updateTypingText.bind(this); this.componentWillReceiveProps = this.componentWillReceiveProps.bind(this); this.typingUsers = {}; @@ -27,7 +27,7 @@ export default class MsgTyping extends React.Component { componentWillReceiveProps(newProps) { if (this.props.channelId !== newProps.channelId) { - this.setState({text: this.getTypingText()}); + this.updateTypingText(); } } @@ -50,31 +50,37 @@ export default class MsgTyping extends React.Component { this.typingUsers[username] = setTimeout(function myTimer(user) { delete this.typingUsers[user]; - this.setState({text: this.getTypingText()}); + this.updateTypingText(); }.bind(this, username), Constants.UPDATE_TYPING_MS); - this.setState({text: this.getTypingText()}); + this.updateTypingText(); } else if (msg.action === SocketEvents.POSTED && msg.channel_id === this.props.channelId) { if (UserStore.hasProfile(msg.user_id)) { username = UserStore.getProfile(msg.user_id).username; } clearTimeout(this.typingUsers[username]); delete this.typingUsers[username]; - this.setState({text: this.getTypingText()}); + this.updateTypingText(); } } - getTypingText() { - let users = Object.keys(this.typingUsers); + updateTypingText() { + const users = Object.keys(this.typingUsers); + let text = ''; switch (users.length) { case 0: - return ''; + text = ''; + break; case 1: - return users[0] + ' is typing...'; + text = users[0] + ' is typing...'; + break; default: const last = users.pop(); - return users.join(', ') + ' and ' + last + ' are typing...'; + text = users.join(', ') + ' and ' + last + ' are typing...'; + break; } + + this.setState({text}); } render() { -- cgit v1.2.3-1-g7c22 From a9ec7215ade2b64f2d5164a12b47d92ed8981233 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Sun, 25 Oct 2015 15:12:36 +0100 Subject: PLT-642: Browser tab alerts --- web/react/components/sidebar.jsx | 61 ++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 12 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx index ed2c84057..0d3577f2d 100644 --- a/web/react/components/sidebar.jsx +++ b/web/react/components/sidebar.jsx @@ -40,6 +40,9 @@ export default class Sidebar extends React.Component { this.hideMoreDirectChannelsModal = this.hideMoreDirectChannelsModal.bind(this); this.createChannelElement = this.createChannelElement.bind(this); + this.updateTitle = this.updateTitle.bind(this); + this.setUnreadCount = this.setUnreadCount.bind(this); + this.getUnreadCount = this.getUnreadCount.bind(this); this.isLeaving = new Map(); @@ -49,8 +52,44 @@ export default class Sidebar extends React.Component { state.loadingDMChannel = -1; state.windowWidth = Utils.windowWidth(); + this.unreadCount = this.setUnreadCount(); this.state = state; } + setUnreadCount() { + const channels = ChannelStore.getAll(); + const members = ChannelStore.getAllMembers(); + const unreadCount = {}; + + channels.forEach((ch) => { + const chMember = members[ch.id]; + let chMentionCount = chMember.mention_count; + let chUnreadCount = ch.total_msg_count - chMember.msg_count - chMentionCount; + + if (ch.type === 'D') { + chMentionCount = chUnreadCount; + chUnreadCount = 0; + } + + unreadCount[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount}; + }); + + return unreadCount; + } + getUnreadCount(channelId) { + let mentions = 0; + let msgs = 0; + + if (channelId) { + return this.unreadCount[channelId] ? this.unreadCount[channelId] : {msgs, mentions}; + } + + Object.keys(this.unreadCount).forEach((chId) => { + msgs += this.unreadCount[chId].msgs; + mentions += this.unreadCount[chId].mentions; + }); + + return {msgs, mentions}; + } getStateFromStores() { const members = ChannelStore.getAllMembers(); var teamMemberMap = UserStore.getActiveOnlyProfiles(); @@ -192,7 +231,10 @@ export default class Sidebar extends React.Component { currentChannelName = Utils.getDirectTeammate(channel.id).username; } - document.title = currentChannelName + ' - ' + this.props.teamDisplayName + ' ' + currentSiteName; + const unread = this.getUnreadCount(); + const mentionTitle = unread.mentions > 0 ? '(' + unread.mentions + ') ' : ''; + const unreadTitle = unread.msgs > 0 ? '* ' : ''; + document.title = mentionTitle + unreadTitle + currentChannelName + ' - ' + this.props.teamDisplayName + ' ' + currentSiteName; } } onScroll() { @@ -273,6 +315,7 @@ export default class Sidebar extends React.Component { var members = this.state.members; var activeId = this.state.activeId; var channelMember = members[channel.id]; + var unreadCount = this.getUnreadCount(channel.id); var msgCount; var linkClass = ''; @@ -284,7 +327,7 @@ export default class Sidebar extends React.Component { var unread = false; if (channelMember) { - msgCount = channel.total_msg_count - channelMember.msg_count; + msgCount = unreadCount.msgs + unreadCount.mentions; unread = (msgCount > 0 && channelMember.notify_props.mark_unread !== 'mention') || channelMember.mention_count > 0; } @@ -301,16 +344,8 @@ export default class Sidebar extends React.Component { var badge = null; if (channelMember) { - if (channel.type === 'D') { - // direct message channels show badges for any number of unread posts - msgCount = channel.total_msg_count - channelMember.msg_count; - if (msgCount > 0) { - badge = {msgCount}; - this.badgesActive = true; - } - } else if (channelMember.mention_count > 0) { - // public and private channels only show badges for mentions - badge = {channelMember.mention_count}; + if (unreadCount.mentions) { + badge = {unreadCount.mentions}; this.badgesActive = true; } } else if (this.state.loadingDMChannel === index && channel.type === 'D') { @@ -434,6 +469,8 @@ export default class Sidebar extends React.Component { render() { this.badgesActive = false; + this.unreadCount = this.setUnreadCount(); + // keep track of the first and last unread channels so we can use them to set the unread indicators this.firstUnreadChannel = null; this.lastUnreadChannel = null; -- cgit v1.2.3-1-g7c22 From a88fe8ea1a9cc020cc0d1dc442d46fc0bed90cc9 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Mon, 26 Oct 2015 17:53:21 +0100 Subject: rename methods and varibles to a more meaningful name --- web/react/components/sidebar.jsx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx index 0d3577f2d..5cb6d168b 100644 --- a/web/react/components/sidebar.jsx +++ b/web/react/components/sidebar.jsx @@ -41,7 +41,7 @@ export default class Sidebar extends React.Component { this.createChannelElement = this.createChannelElement.bind(this); this.updateTitle = this.updateTitle.bind(this); - this.setUnreadCount = this.setUnreadCount.bind(this); + this.setUnreadCountPerChannel = this.setUnreadCountPerChannel.bind(this); this.getUnreadCount = this.getUnreadCount.bind(this); this.isLeaving = new Map(); @@ -51,14 +51,15 @@ export default class Sidebar extends React.Component { state.showDirectChannelsModal = false; state.loadingDMChannel = -1; state.windowWidth = Utils.windowWidth(); - - this.unreadCount = this.setUnreadCount(); this.state = state; + + this.unreadCountPerChannel = {}; + this.setUnreadCountPerChannel(); } - setUnreadCount() { + setUnreadCountPerChannel() { const channels = ChannelStore.getAll(); const members = ChannelStore.getAllMembers(); - const unreadCount = {}; + const channelUnreadCounts = {}; channels.forEach((ch) => { const chMember = members[ch.id]; @@ -70,22 +71,22 @@ export default class Sidebar extends React.Component { chUnreadCount = 0; } - unreadCount[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount}; + channelUnreadCounts[ch.id] = {msgs: chUnreadCount, mentions: chMentionCount}; }); - return unreadCount; + this.unreadCountPerChannel = channelUnreadCounts; } getUnreadCount(channelId) { let mentions = 0; let msgs = 0; if (channelId) { - return this.unreadCount[channelId] ? this.unreadCount[channelId] : {msgs, mentions}; + return this.unreadCountPerChannel[channelId] ? this.unreadCountPerChannel[channelId] : {msgs, mentions}; } - Object.keys(this.unreadCount).forEach((chId) => { - msgs += this.unreadCount[chId].msgs; - mentions += this.unreadCount[chId].mentions; + Object.keys(this.unreadCountPerChannel).forEach((chId) => { + msgs += this.unreadCountPerChannel[chId].msgs; + mentions += this.unreadCountPerChannel[chId].mentions; }); return {msgs, mentions}; @@ -469,7 +470,7 @@ export default class Sidebar extends React.Component { render() { this.badgesActive = false; - this.unreadCount = this.setUnreadCount(); + this.setUnreadCountPerChannel(); // keep track of the first and last unread channels so we can use them to set the unread indicators this.firstUnreadChannel = null; -- cgit v1.2.3-1-g7c22 From 6d957a26d884cd2ff200a4d14b035bc03415cab6 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 26 Oct 2015 10:42:54 -0700 Subject: PLT-564 removing auto-hide from error bar --- web/react/components/error_bar.jsx | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/error_bar.jsx b/web/react/components/error_bar.jsx index 6311d9460..f098384aa 100644 --- a/web/react/components/error_bar.jsx +++ b/web/react/components/error_bar.jsx @@ -9,12 +9,8 @@ export default class ErrorBar extends React.Component { this.onErrorChange = this.onErrorChange.bind(this); this.handleClose = this.handleClose.bind(this); - this.prevTimer = null; this.state = ErrorStore.getLastError(); - if (this.isValidError(this.state)) { - this.prevTimer = setTimeout(this.handleClose, 10000); - } } isValidError(s) { @@ -56,16 +52,8 @@ export default class ErrorBar extends React.Component { onErrorChange() { var newState = ErrorStore.getLastError(); - if (this.prevTimer != null) { - clearInterval(this.prevTimer); - this.prevTimer = null; - } - if (newState) { this.setState(newState); - if (!this.isConnectionError(newState)) { - this.prevTimer = setTimeout(this.handleClose, 10000); - } } else { this.setState({message: null}); } -- cgit v1.2.3-1-g7c22 From ff6e91f51d844a4703d3c4648b8b6bffe0cdabbc Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 26 Oct 2015 14:15:07 -0400 Subject: Fixed file upload and profile picture upload error display to work for serverside errors --- web/react/components/create_post.jsx | 10 ++++++++-- web/react/components/user_settings/user_settings_general.jsx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index 055be112d..0867bfdf2 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -253,8 +253,14 @@ export default class CreatePost extends React.Component { this.setState({uploadsInProgress: draft.uploadsInProgress, previews: draft.previews}); } handleUploadError(err, clientId) { + let message = err; + if (message && typeof message !== 'string') { + // err is an AppError from the server + message = err.message; + } + if (clientId === -1) { - this.setState({serverError: err}); + this.setState({serverError: message}); } else { const draft = PostStore.getDraft(this.state.channelId); @@ -265,7 +271,7 @@ export default class CreatePost extends React.Component { PostStore.storeDraft(this.state.channelId, draft); - this.setState({uploadsInProgress: draft.uploadsInProgress, serverError: err}); + this.setState({uploadsInProgress: draft.uploadsInProgress, serverError: message}); } } handleTextDrop(text) { diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx index 70e559c30..1c8ce3c79 100644 --- a/web/react/components/user_settings/user_settings_general.jsx +++ b/web/react/components/user_settings/user_settings_general.jsx @@ -171,7 +171,7 @@ export default class UserSettingsGeneralTab extends React.Component { }.bind(this), function imageUploadFailure(err) { var state = this.setupInitialState(this.props); - state.serverError = err; + state.serverError = err.message; this.setState(state); }.bind(this) ); -- cgit v1.2.3-1-g7c22