Merge pull request #2110 from matrix-org/dbkr/no_connection_lost_on_mau_bar
Don't show 'connection lost' bar on MAU errorpull/21833/head
						commit
						eb47abc055
					
				|  | @ -1,7 +1,7 @@ | |||
| /* | ||||
| Copyright 2015, 2016 OpenMarket Ltd | ||||
| Copyright 2017 Vector Creations Ltd | ||||
| Copyright 2017 New Vector Ltd | ||||
| Copyright 2017, 2018 New Vector Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
|  | @ -144,7 +144,9 @@ const LoggedInView = React.createClass({ | |||
|     }, | ||||
| 
 | ||||
|     onSync: function(syncState, oldSyncState, data) { | ||||
|         if (syncState === oldSyncState) return; | ||||
|         const oldErrCode = this.state.syncErrorData && this.state.syncErrorData.error && this.state.syncErrorData.error.errcode; | ||||
|         const newErrCode = data && data.error && data.error.errcode; | ||||
|         if (syncState === oldSyncState && oldErrCode === newErrCode) return; | ||||
| 
 | ||||
|         if (syncState === 'ERROR') { | ||||
|             this.setState({ | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| /* | ||||
| Copyright 2015, 2016 OpenMarket Ltd | ||||
| Copyright 2017 New Vector Ltd | ||||
| Copyright 2017, 2018 New Vector Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
|  | @ -107,6 +107,7 @@ module.exports = React.createClass({ | |||
|     getInitialState: function() { | ||||
|         return { | ||||
|             syncState: MatrixClientPeg.get().getSyncState(), | ||||
|             syncStateData: MatrixClientPeg.get().getSyncStateData(), | ||||
|             usersTyping: WhoIsTyping.usersTypingApartFromMe(this.props.room), | ||||
|             unsentMessages: getUnsentMessages(this.props.room), | ||||
|         }; | ||||
|  | @ -134,12 +135,13 @@ module.exports = React.createClass({ | |||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     onSyncStateChange: function(state, prevState) { | ||||
|     onSyncStateChange: function(state, prevState, data) { | ||||
|         if (state === "SYNCING" && prevState === "SYNCING") { | ||||
|             return; | ||||
|         } | ||||
|         this.setState({ | ||||
|             syncState: state, | ||||
|             syncStateData: data, | ||||
|         }); | ||||
|     }, | ||||
| 
 | ||||
|  | @ -191,7 +193,7 @@ module.exports = React.createClass({ | |||
|     // changed - so we use '0' to indicate normal size, and other values to
 | ||||
|     // indicate other sizes.
 | ||||
|     _getSize: function() { | ||||
|         if (this.state.syncState === "ERROR" || | ||||
|         if (this._shouldShowConnectionError() || | ||||
|             (this.state.usersTyping.length > 0) || | ||||
|             this.props.numUnreadMessages || | ||||
|             !this.props.atEndOfLiveTimeline || | ||||
|  | @ -238,7 +240,7 @@ module.exports = React.createClass({ | |||
|             ); | ||||
|         } | ||||
| 
 | ||||
|         if (this.state.syncState === "ERROR") { | ||||
|         if (this._shouldShowConnectionError()) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | @ -285,6 +287,21 @@ module.exports = React.createClass({ | |||
|         return avatars; | ||||
|     }, | ||||
| 
 | ||||
|     _shouldShowConnectionError: function() { | ||||
|         // no conn bar trumps unread count since you can't get unread messages
 | ||||
|         // without a connection! (technically may already have some but meh)
 | ||||
|         // It also trumps the "some not sent" msg since you can't resend without
 | ||||
|         // a connection!
 | ||||
|         // There's one situation in which we don't show this 'no connection' bar, and that's
 | ||||
|         // if it's a monthly-active-user limit error: those are shown in the top bar.
 | ||||
|         const errorIsMauError = Boolean( | ||||
|             this.state.syncStateData && | ||||
|             this.state.syncStateData.error && | ||||
|             this.state.syncStateData.error.errcode === 'M_MAU_LIMIT_EXCEEDED' | ||||
|         ); | ||||
|         return this.state.syncState === "ERROR" && !errorIsMauError; | ||||
|     }, | ||||
| 
 | ||||
|     _getUnsentMessageContent: function() { | ||||
|         const unsentMessages = this.state.unsentMessages; | ||||
|         if (!unsentMessages.length) return null; | ||||
|  | @ -372,11 +389,7 @@ module.exports = React.createClass({ | |||
|     _getContent: function() { | ||||
|         const EmojiText = sdk.getComponent('elements.EmojiText'); | ||||
| 
 | ||||
|         // no conn bar trumps unread count since you can't get unread messages
 | ||||
|         // without a connection! (technically may already have some but meh)
 | ||||
|         // It also trumps the "some not sent" msg since you can't resend without
 | ||||
|         // a connection!
 | ||||
|         if (this.state.syncState === "ERROR") { | ||||
|         if (this._shouldShowConnectionError()) { | ||||
|             return ( | ||||
|                 <div className="mx_RoomStatusBar_connectionLostBar"> | ||||
|                     <img src="img/warning.svg" width="24" height="23" title="/!\ " alt="/!\ " /> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Bruno Windels
						Bruno Windels