Этот коммит содержится в:
Christopher Speller
2016-11-24 09:08:46 -05:00
родитель b212acf312 36f62c9e82
Коммит c96ecae6da
15 изменённых файлов: 137 добавлений и 45 удалений

Просмотреть файл

@@ -68,12 +68,18 @@ export default class ChannelHeader extends React.Component {
const stats = ChannelStore.getStats(this.props.channelId);
const users = UserStore.getProfileListInChannel(this.props.channelId);
let otherUserId = null;
if (channel && channel.type === 'D') {
otherUserId = Utils.getUserIdFromChannelName(channel);
}
return {
channel,
memberChannel: ChannelStore.getMyMember(this.props.channelId),
users,
userCount: stats.member_count,
currentUser: UserStore.getCurrentUser(),
otherUserId,
enableFormatting: PreferenceStore.getBool(Preferences.CATEGORY_ADVANCED_SETTINGS, 'formatting', true),
isBusy: WebrtcStore.isBusy(),
isFavorite: channel && ChannelUtils.isFavoriteChannel(channel)
@@ -84,7 +90,6 @@ export default class ChannelHeader extends React.Component {
if (!this.state.channel ||
!this.state.memberChannel ||
!this.state.users ||
(Object.keys(this.state.users).length === 0 && this.state.channel.type === 'D') ||
!this.state.userCount ||
!this.state.currentUser) {
return false;
@@ -240,7 +245,10 @@ export default class ChannelHeader extends React.Component {
const flagIcon = Constants.FLAG_ICON_SVG;
if (!this.validState()) {
return null;
// Use an empty div to make sure the header's height stays constant
return (
<div className='channel-header'/>
);
}
const channel = this.state.channel;
@@ -285,7 +293,7 @@ export default class ChannelHeader extends React.Component {
if (isDirect) {
const userMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
const contact = this.state.users[0];
const otherUserId = this.state.otherUserId;
const teammateId = Utils.getUserIdFromChannelName(channel);
channelTitle = Utils.displayUsername(teammateId);
@@ -293,7 +301,7 @@ export default class ChannelHeader extends React.Component {
const webrtcEnabled = global.mm_config.EnableWebrtc === 'true' && userMedia && Utils.isFeatureEnabled(PreReleaseFeatures.WEBRTC_PREVIEW);
if (webrtcEnabled) {
const isOffline = UserStore.getStatus(contact.id) === UserStatuses.OFFLINE;
const isOffline = UserStore.getStatus(otherUserId) === UserStatuses.OFFLINE;
const busy = this.state.isBusy;
let circleClass = '';
let webrtcMessage;
@@ -332,7 +340,7 @@ export default class ChannelHeader extends React.Component {
<div className='webrtc__header'>
<a
href='#'
onClick={() => this.initWebrtc(contact.id, !isOffline)}
onClick={() => this.initWebrtc(otherUserId, !isOffline)}
disabled={isOffline}
>
<OverlayTrigger

Просмотреть файл

@@ -51,6 +51,7 @@ export default class CodePreview extends React.Component {
async: true,
url: props.fileUrl,
type: 'GET',
dataType: 'text',
error: this.handleReceivedError,
success: this.handleReceivedCode
});
@@ -61,7 +62,11 @@ export default class CodePreview extends React.Component {
if (data.nodeName === '#document') {
code = new XMLSerializer().serializeToString(data);
}
this.setState({code, loading: false, success: true});
this.setState({
code,
loading: false,
success: true
});
}
handleReceivedError() {

Просмотреть файл

@@ -17,11 +17,12 @@ export default class PostViewCache extends React.Component {
this.onChannelChange = this.onChannelChange.bind(this);
const currentChannelId = ChannelStore.getCurrentId();
const channel = ChannelStore.getCurrent();
this.state = {
currentChannelId: channel.id,
channels: [channel]
currentChannelId,
channels: channel ? [channel] : []
};
}
@@ -40,7 +41,7 @@ export default class PostViewCache extends React.Component {
const channels = Object.assign([], this.state.channels);
const currentChannel = ChannelStore.getCurrent();
if (currentChannel == null) {
if (!currentChannel) {
return;
}

Просмотреть файл

@@ -202,8 +202,13 @@ export default class PostViewController extends React.Component {
}
}
onSetNewMessageIndicator(lastViewed, ownNewMessage) {
this.setState({lastViewed, ownNewMessage});
onSetNewMessageIndicator() {
let lastViewed = Number.MAX_VALUE;
const member = ChannelStore.getMyMember(this.props.channel.id);
if (member != null) {
lastViewed = member.last_viewed_at;
}
this.setState({lastViewed});
}
onPostListScroll(atBottom) {

Просмотреть файл

@@ -90,7 +90,7 @@ export default class RhsRootPost extends React.Component {
var isOwner = this.props.currentUser.id === post.user_id;
var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser();
const isSystemMessage = post.type && post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX);
var timestamp = user.update_at;
var timestamp = user ? user.update_at : 0;
var channel = ChannelStore.get(post.channel_id);
const flagIcon = Constants.FLAG_ICON_SVG;

Просмотреть файл

@@ -45,6 +45,7 @@ export default class SidebarHeaderDropdown extends React.Component {
this.showGetTeamInviteLinkModal = this.showGetTeamInviteLinkModal.bind(this);
this.showTeamMembersModal = this.showTeamMembersModal.bind(this);
this.hideTeamMembersModal = this.hideTeamMembersModal.bind(this);
this.handleSwitchTeams = this.handleSwitchTeams.bind(this);
this.onTeamChange = this.onTeamChange.bind(this);
this.openAccountSettings = this.openAccountSettings.bind(this);
@@ -131,6 +132,11 @@ export default class SidebarHeaderDropdown extends React.Component {
});
}
handleSwitchTeams() {
// The actual switching of teams is handled by the react-router Link
this.setState({showDropdown: false});
}
componentDidMount() {
TeamStore.addChangeListener(this.onTeamChange);
document.addEventListener('keydown', this.openAccountSettings);
@@ -367,6 +373,7 @@ export default class SidebarHeaderDropdown extends React.Component {
<li key={'team_' + team.name}>
<Link
to={'/' + team.name + '/channels/town-square'}
onClick={this.handleSwitchTeams}
>
<FormattedMessage
id='navbar_dropdown.switchTo'