Fixed edge cases with leaving a direct channel while viewing that channel
Этот коммит содержится в:
@@ -82,21 +82,6 @@ export default class MoreDirectChannels extends React.Component {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (channel.id === ChannelStore.getCurrentId()) {
|
|
||||||
active = 'active';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel.unread) {
|
|
||||||
badge = <span className='badge pull-right small'>{channel.unread}</span>;
|
|
||||||
titleClass = 'unread-title';
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClick = function clickHandler(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
utils.switchChannel(channel);
|
|
||||||
$(React.findDOMNode(self.refs.modal)).modal('hide');
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ export default class Sidebar extends React.Component {
|
|||||||
this.handleLeaveDirectChannel = this.handleLeaveDirectChannel.bind(this);
|
this.handleLeaveDirectChannel = this.handleLeaveDirectChannel.bind(this);
|
||||||
this.createChannelElement = this.createChannelElement.bind(this);
|
this.createChannelElement = this.createChannelElement.bind(this);
|
||||||
|
|
||||||
|
this.isLeaving = new Map();
|
||||||
|
|
||||||
const state = this.getStateFromStores();
|
const state = this.getStateFromStores();
|
||||||
state.modal = '';
|
state.modal = '';
|
||||||
state.loadingDMChannel = -1;
|
state.loadingDMChannel = -1;
|
||||||
@@ -85,7 +87,8 @@ export default class Sidebar extends React.Component {
|
|||||||
const member = members[channel.id];
|
const member = members[channel.id];
|
||||||
const msgCount = channel.total_msg_count - member.msg_count;
|
const msgCount = channel.total_msg_count - member.msg_count;
|
||||||
|
|
||||||
forceShow = currentId === channel.id || msgCount > 0;
|
// always show a channel if either it is the current one or if it is unread, but it is not currently being left
|
||||||
|
forceShow = (currentId === channel.id || msgCount > 0) && !this.isLeaving.get(channel.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.display_name = teammate.username;
|
channel.display_name = teammate.username;
|
||||||
@@ -93,8 +96,10 @@ export default class Sidebar extends React.Component {
|
|||||||
channel.status = UserStore.getStatus(teammate.id);
|
channel.status = UserStore.getStatus(teammate.id);
|
||||||
|
|
||||||
if (preferences.some((preference) => (preference.alt_id === teammate.id && preference.value !== 'false'))) {
|
if (preferences.some((preference) => (preference.alt_id === teammate.id && preference.value !== 'false'))) {
|
||||||
|
console.log(teammate.id + " is visible");
|
||||||
visibleDirectChannels.push(channel);
|
visibleDirectChannels.push(channel);
|
||||||
} else if (forceShow) {
|
} else if (forceShow) {
|
||||||
|
console.log(teammate.id + " needs to be visible");
|
||||||
// make sure that unread direct channels are visible
|
// make sure that unread direct channels are visible
|
||||||
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
|
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
|
||||||
Constants.Preferences.NAME_SHOW, teammate.id, 'true');
|
Constants.Preferences.NAME_SHOW, teammate.id, 'true');
|
||||||
@@ -304,18 +309,18 @@ export default class Sidebar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleLeaveDirectChannel(channel) {
|
handleLeaveDirectChannel(channel) {
|
||||||
if (!channel.leaving) {
|
if (!this.isLeaving.get(channel.id)) {
|
||||||
channel.leaving = true;
|
this.isLeaving.set(channel.id, true);
|
||||||
|
|
||||||
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
|
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
|
||||||
Constants.Preferences.NAME_SHOW, channel.teammate_id, 'false');
|
Constants.Preferences.NAME_SHOW, channel.teammate_id, 'false');
|
||||||
AsyncClient.setPreferences(
|
AsyncClient.setPreferences(
|
||||||
[preference],
|
[preference],
|
||||||
() => {
|
() => {
|
||||||
channel.leaving = false;
|
this.isLeaving.set(channel.id, false);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
channel.leaving = false;
|
this.isLeaving.set(channel.id, false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class PreferenceStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAllPreferences() {
|
getAllPreferences() {
|
||||||
console.log('getting preferences'); // eslint-disable-line no-console
|
|
||||||
return new Map(BrowserStore.getItem('preferences', []));
|
return new Map(BrowserStore.getItem('preferences', []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1159,6 +1159,7 @@ export function setPreferences(preferences, success, error) {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/api/v1/preferences/set',
|
url: '/api/v1/preferences/set',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
contentType: 'application/json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: JSON.stringify(preferences),
|
data: JSON.stringify(preferences),
|
||||||
success,
|
success,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user