Check if we need to add DM/GM to sidebar regardless of post sender (#6009)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
9318ffcdf3
Коммит
86fbd496af
@@ -300,7 +300,7 @@ export function loadDMsAndGMsForUnreads() {
|
|||||||
if (unreads[id].msgs > 0 || unreads[id].mentions > 0) {
|
if (unreads[id].msgs > 0 || unreads[id].mentions > 0) {
|
||||||
const channel = ChannelStore.get(id);
|
const channel = ChannelStore.get(id);
|
||||||
if (channel && channel.type === Constants.DM_CHANNEL) {
|
if (channel && channel.type === Constants.DM_CHANNEL) {
|
||||||
loadNewDMIfNeeded(Utils.getUserIdFromChannelName(channel));
|
loadNewDMIfNeeded(channel.id);
|
||||||
} else if (channel && channel.type === Constants.GM_CHANNEL) {
|
} else if (channel && channel.type === Constants.GM_CHANNEL) {
|
||||||
loadNewGMIfNeeded(channel.id);
|
loadNewGMIfNeeded(channel.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,12 @@ export function sendDesktopNotification(post, msgProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (title === '') {
|
if (title === '') {
|
||||||
|
if (msgProps.channel_type === Constants.DM_CHANNEL) {
|
||||||
|
title = Utils.localizeMessage('notification.dm', 'Direct Message');
|
||||||
|
} else {
|
||||||
title = msgProps.channel_display_name;
|
title = msgProps.channel_display_name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let notifyText = post.message.replace(/\n+/g, ' ');
|
let notifyText = post.message.replace(/\n+/g, ' ');
|
||||||
if (notifyText.length > 50) {
|
if (notifyText.length > 50) {
|
||||||
|
|||||||
@@ -20,19 +20,11 @@ const ActionTypes = Constants.ActionTypes;
|
|||||||
const Preferences = Constants.Preferences;
|
const Preferences = Constants.Preferences;
|
||||||
|
|
||||||
export function handleNewPost(post, msg) {
|
export function handleNewPost(post, msg) {
|
||||||
let websocketMessageProps = null;
|
let websocketMessageProps = {};
|
||||||
if (msg) {
|
if (msg) {
|
||||||
websocketMessageProps = msg.data;
|
websocketMessageProps = msg.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg && msg.data) {
|
|
||||||
if (msg.data.channel_type === Constants.DM_CHANNEL) {
|
|
||||||
loadNewDMIfNeeded(post.user_id);
|
|
||||||
} else if (msg.data.channel_type === Constants.GM_CHANNEL) {
|
|
||||||
loadNewGMIfNeeded(post.channel_id, post.user_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ChannelStore.getMyMember(post.channel_id)) {
|
if (ChannelStore.getMyMember(post.channel_id)) {
|
||||||
completePostReceive(post, websocketMessageProps);
|
completePostReceive(post, websocketMessageProps);
|
||||||
} else {
|
} else {
|
||||||
@@ -43,6 +35,14 @@ export function handleNewPost(post, msg) {
|
|||||||
|
|
||||||
AsyncClient.getChannelMember(post.channel_id, UserStore.getCurrentId()).then(() => completePostReceive(post, websocketMessageProps));
|
AsyncClient.getChannelMember(post.channel_id, UserStore.getCurrentId()).then(() => completePostReceive(post, websocketMessageProps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg && msg.data) {
|
||||||
|
if (msg.data.channel_type === Constants.DM_CHANNEL) {
|
||||||
|
loadNewDMIfNeeded(post.channel_id);
|
||||||
|
} else if (msg.data.channel_type === Constants.GM_CHANNEL) {
|
||||||
|
loadNewGMIfNeeded(post.channel_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function completePostReceive(post, websocketMessageProps) {
|
function completePostReceive(post, websocketMessageProps) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ChannelStore from 'stores/channel_store.jsx';
|
|||||||
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
|
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
|
||||||
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
|
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
|
||||||
|
|
||||||
import {getDirectChannelName} from 'utils/utils.jsx';
|
import {getDirectChannelName, getUserIdFromChannelName} from 'utils/utils.jsx';
|
||||||
|
|
||||||
import * as AsyncClient from 'utils/async_client.jsx';
|
import * as AsyncClient from 'utils/async_client.jsx';
|
||||||
import Client from 'client/web_client.jsx';
|
import Client from 'client/web_client.jsx';
|
||||||
@@ -255,8 +255,11 @@ function populateChannelWithProfiles(channelId, userIds) {
|
|||||||
UserStore.emitInChannelChange();
|
UserStore.emitInChannelChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadNewDMIfNeeded(userId) {
|
export function loadNewDMIfNeeded(channelId) {
|
||||||
if (userId === UserStore.getCurrentId()) {
|
function checkPreference(channel) {
|
||||||
|
const userId = getUserIdFromChannelName(channel);
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,13 +269,31 @@ export function loadNewDMIfNeeded(userId) {
|
|||||||
AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
|
AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
|
||||||
loadProfilesForDM();
|
loadProfilesForDM();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export function loadNewGMIfNeeded(channelId, userId) {
|
|
||||||
if (userId === UserStore.getCurrentId()) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const channel = ChannelStore.get(channelId);
|
||||||
|
if (channel) {
|
||||||
|
checkPreference(channel);
|
||||||
|
} else {
|
||||||
|
Client.getChannel(
|
||||||
|
channelId,
|
||||||
|
(data) => {
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.RECEIVED_CHANNEL,
|
||||||
|
channel: data.channel,
|
||||||
|
member: data.member
|
||||||
|
});
|
||||||
|
|
||||||
|
checkPreference(data.channel);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
AsyncClient.dispatchError(err, 'getChannel');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadNewGMIfNeeded(channelId) {
|
||||||
function checkPreference() {
|
function checkPreference() {
|
||||||
const pref = PreferenceStore.getBool(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, false);
|
const pref = PreferenceStore.getBool(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, false);
|
||||||
if (pref === false) {
|
if (pref === false) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
|||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
const ActionTypes = Constants.ActionTypes;
|
const ActionTypes = Constants.ActionTypes;
|
||||||
import * as AsyncClient from 'utils/async_client.jsx';
|
import * as AsyncClient from 'utils/async_client.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
|
||||||
import Client from 'client/web_client.jsx';
|
import Client from 'client/web_client.jsx';
|
||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
import BrowserStore from 'stores/browser_store.jsx';
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
@@ -35,7 +34,7 @@ function doChannelChange(state, replace, callback) {
|
|||||||
channel = ChannelStore.getByName(state.params.channel);
|
channel = ChannelStore.getByName(state.params.channel);
|
||||||
|
|
||||||
if (channel && channel.type === Constants.DM_CHANNEL) {
|
if (channel && channel.type === Constants.DM_CHANNEL) {
|
||||||
loadNewDMIfNeeded(Utils.getUserIdFromChannelName(channel));
|
loadNewDMIfNeeded(channel.id);
|
||||||
} else if (channel && channel.type === Constants.GM_CHANNEL) {
|
} else if (channel && channel.type === Constants.GM_CHANNEL) {
|
||||||
loadNewGMIfNeeded(channel.id);
|
loadNewGMIfNeeded(channel.id);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user