PLT-5653 Fix Create channel does not show in another device (#5548)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
72de977c52
Коммит
48f97a5a2a
@@ -105,6 +105,10 @@ func CreateChannelWithUser(channel *model.Channel, userId string) (*model.Channe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_CREATED, "", "", userId, nil)
|
||||
message.Add("channel_id", channel.Id)
|
||||
Publish(message)
|
||||
|
||||
return rchannel, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ const (
|
||||
WEBSOCKET_EVENT_POST_EDITED = "post_edited"
|
||||
WEBSOCKET_EVENT_POST_DELETED = "post_deleted"
|
||||
WEBSOCKET_EVENT_CHANNEL_DELETED = "channel_deleted"
|
||||
WEBSOCKET_EVENT_CHANNEL_CREATED = "channel_created"
|
||||
WEBSOCKET_EVENT_DIRECT_ADDED = "direct_added"
|
||||
WEBSOCKET_EVENT_NEW_USER = "new_user"
|
||||
WEBSOCKET_EVENT_LEAVE_TEAM = "leave_team"
|
||||
|
||||
@@ -335,27 +335,34 @@ export function createChannel(channel, success, error) {
|
||||
Client.createChannel(
|
||||
channel,
|
||||
(data) => {
|
||||
Client.getChannel(
|
||||
data.id,
|
||||
(data2) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_CHANNEL,
|
||||
channel: data2.channel,
|
||||
member: data2.channel
|
||||
});
|
||||
|
||||
if (success) {
|
||||
success(data2);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'getChannel');
|
||||
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
const existing = ChannelStore.getChannelById(data.id);
|
||||
if (existing) {
|
||||
if (success) {
|
||||
success({channel: existing});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
Client.getChannel(
|
||||
data.id,
|
||||
(data2) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_CHANNEL,
|
||||
channel: data2.channel,
|
||||
member: data2.channel
|
||||
});
|
||||
|
||||
if (success) {
|
||||
success(data2);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'getChannel');
|
||||
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'createChannel');
|
||||
|
||||
@@ -6,6 +6,7 @@ import $ from 'jquery';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
import TeamStore from 'stores/team_store.jsx';
|
||||
import PostStore from 'stores/post_store.jsx';
|
||||
import PreferenceStore from 'stores/preference_store.jsx';
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
import BrowserStore from 'stores/browser_store.jsx';
|
||||
import ErrorStore from 'stores/error_store.jsx';
|
||||
@@ -25,7 +26,7 @@ import {loadProfilesAndTeamMembersForDMSidebar} from 'actions/user_actions.jsx';
|
||||
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
|
||||
import * as StatusActions from 'actions/status_actions.jsx';
|
||||
|
||||
import {ActionTypes, Constants, SocketEvents, UserStatuses} from 'utils/constants.jsx';
|
||||
import {ActionTypes, Constants, Preferences, SocketEvents, UserStatuses} from 'utils/constants.jsx';
|
||||
|
||||
import {browserHistory} from 'react-router/es6';
|
||||
|
||||
@@ -137,6 +138,10 @@ function handleEvent(msg) {
|
||||
handleUserUpdatedEvent(msg);
|
||||
break;
|
||||
|
||||
case SocketEvents.CHANNEL_CREATED:
|
||||
handleChannelCreatedEvent(msg);
|
||||
break;
|
||||
|
||||
case SocketEvents.CHANNEL_DELETED:
|
||||
handleChannelDeletedEvent(msg);
|
||||
break;
|
||||
@@ -238,6 +243,7 @@ function handleUpdateTeamEvent(msg) {
|
||||
|
||||
function handleDirectAddedEvent(msg) {
|
||||
AsyncClient.getChannel(msg.broadcast.channel_id);
|
||||
PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, msg.data.teammate_id, 'true');
|
||||
loadProfilesAndTeamMembersForDMSidebar();
|
||||
}
|
||||
|
||||
@@ -278,6 +284,14 @@ function handleUserUpdatedEvent(msg) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleChannelCreatedEvent(msg) {
|
||||
const channelId = msg.data.channel_id;
|
||||
|
||||
if (!ChannelStore.getChannelById(channelId)) {
|
||||
AsyncClient.getChannel(channelId);
|
||||
}
|
||||
}
|
||||
|
||||
function handleChannelDeletedEvent(msg) {
|
||||
if (ChannelStore.getCurrentId() === msg.data.channel_id) {
|
||||
const teamUrl = TeamStore.getCurrentTeamRelativeUrl();
|
||||
|
||||
@@ -203,6 +203,7 @@ export const SocketEvents = {
|
||||
POSTED: 'posted',
|
||||
POST_EDITED: 'post_edited',
|
||||
POST_DELETED: 'post_deleted',
|
||||
CHANNEL_CREATED: 'channel_created',
|
||||
CHANNEL_DELETED: 'channel_deleted',
|
||||
CHANNEL_VIEWED: 'channel_viewed',
|
||||
DIRECT_ADDED: 'direct_added',
|
||||
|
||||
Ссылка в новой задаче
Block a user