Fixing new messages indicator (#4531)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
29efeff095
Коммит
ced5f54500
@@ -43,16 +43,20 @@ export function emitChannelClickEvent(channel) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
function switchToChannel(chan) {
|
function switchToChannel(chan) {
|
||||||
AsyncClient.getChannelStats(chan.id, true);
|
const getMyChannelMembersPromise = AsyncClient.getChannelMember(chan.id, UserStore.getCurrentId());
|
||||||
AsyncClient.updateLastViewedAt(chan.id);
|
|
||||||
loadPosts(chan.id);
|
|
||||||
trackPage();
|
|
||||||
|
|
||||||
AppDispatcher.handleViewAction({
|
getMyChannelMembersPromise.then(() => {
|
||||||
type: ActionTypes.CLICK_CHANNEL,
|
AsyncClient.getChannelStats(chan.id, true);
|
||||||
name: chan.name,
|
AsyncClient.updateLastViewedAt(chan.id);
|
||||||
id: chan.id,
|
loadPosts(chan.id);
|
||||||
prev: ChannelStore.getCurrentId()
|
trackPage();
|
||||||
|
|
||||||
|
AppDispatcher.handleViewAction({
|
||||||
|
type: ActionTypes.CLICK_CHANNEL,
|
||||||
|
name: chan.name,
|
||||||
|
id: chan.id,
|
||||||
|
prev: ChannelStore.getCurrentId()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,6 +263,12 @@ class ChannelStoreClass extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUnreadCountsByCurrentMembers() {
|
||||||
|
Object.keys(this.myChannelMembers).forEach((key) => {
|
||||||
|
this.setUnreadCountByChannel(this.myChannelMembers[key].channel_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setUnreadCountsByChannels(channels) {
|
setUnreadCountsByChannels(channels) {
|
||||||
channels.forEach((c) => {
|
channels.forEach((c) => {
|
||||||
this.setUnreadCountByChannel(c.id);
|
this.setUnreadCountByChannel(c.id);
|
||||||
@@ -368,6 +374,15 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
ChannelStore.setUnreadCountsByMembers(action.members);
|
ChannelStore.setUnreadCountsByMembers(action.members);
|
||||||
ChannelStore.emitChange();
|
ChannelStore.emitChange();
|
||||||
break;
|
break;
|
||||||
|
case ActionTypes.RECEIVED_CHANNEL_MEMBER:
|
||||||
|
ChannelStore.storeMyChannelMember(action.member);
|
||||||
|
currentId = ChannelStore.getCurrentId();
|
||||||
|
if (currentId && window.isActive) {
|
||||||
|
ChannelStore.resetCounts(currentId);
|
||||||
|
}
|
||||||
|
ChannelStore.setUnreadCountsByCurrentMembers();
|
||||||
|
ChannelStore.emitChange();
|
||||||
|
break;
|
||||||
case ActionTypes.RECEIVED_MORE_CHANNELS:
|
case ActionTypes.RECEIVED_MORE_CHANNELS:
|
||||||
ChannelStore.storeMoreChannels(action.channels);
|
ChannelStore.storeMoreChannels(action.channels);
|
||||||
ChannelStore.emitChange();
|
ChannelStore.emitChange();
|
||||||
@@ -385,4 +400,4 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ChannelStore;
|
export default ChannelStore;
|
||||||
|
|||||||
@@ -111,26 +111,31 @@ export function getChannel(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getMyChannelMembers() {
|
export function getMyChannelMembers() {
|
||||||
if (isCallInProgress('getMyChannelMembers')) {
|
return new Promise((resolve, reject) => {
|
||||||
return;
|
if (isCallInProgress('getMyChannelMembers')) {
|
||||||
}
|
resolve();
|
||||||
|
return;
|
||||||
callTracker.getMyChannelMembers = utils.getTimestamp();
|
|
||||||
|
|
||||||
Client.getMyChannelMembers(
|
|
||||||
(data) => {
|
|
||||||
callTracker.getMyChannelMembers = 0;
|
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS,
|
|
||||||
members: data
|
|
||||||
});
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
callTracker.getChannelsUnread = 0;
|
|
||||||
dispatchError(err, 'getMyChannelMembers');
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
callTracker.getMyChannelMembers = utils.getTimestamp();
|
||||||
|
|
||||||
|
Client.getMyChannelMembers(
|
||||||
|
(data) => {
|
||||||
|
callTracker.getMyChannelMembers = 0;
|
||||||
|
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS,
|
||||||
|
members: data
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
callTracker.getChannelsUnread = 0;
|
||||||
|
dispatchError(err, 'getMyChannelMembers');
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateLastViewedAt(id, active) {
|
export function updateLastViewedAt(id, active) {
|
||||||
@@ -263,28 +268,33 @@ export function getChannelStats(channelId = ChannelStore.getCurrentId(), doVersi
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getChannelMember(channelId, userId) {
|
export function getChannelMember(channelId, userId) {
|
||||||
if (isCallInProgress(`getChannelMember${channelId}${userId}`)) {
|
return new Promise((resolve, reject) => {
|
||||||
return;
|
if (isCallInProgress(`getChannelMember${channelId}${userId}`)) {
|
||||||
}
|
resolve();
|
||||||
|
return;
|
||||||
callTracker[`getChannelMember${channelId}${userId}`] = utils.getTimestamp();
|
|
||||||
|
|
||||||
Client.getChannelMember(
|
|
||||||
channelId,
|
|
||||||
userId,
|
|
||||||
(data) => {
|
|
||||||
callTracker[`getChannelMember${channelId}${userId}`] = 0;
|
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_CHANNEL_MEMBER,
|
|
||||||
member: data
|
|
||||||
});
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
callTracker[`getChannelMember${channelId}${userId}`] = 0;
|
|
||||||
dispatchError(err, 'getChannelMember');
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
callTracker[`getChannelMember${channelId}${userId}`] = utils.getTimestamp();
|
||||||
|
|
||||||
|
Client.getChannelMember(
|
||||||
|
channelId,
|
||||||
|
userId,
|
||||||
|
(data) => {
|
||||||
|
callTracker[`getChannelMember${channelId}${userId}`] = 0;
|
||||||
|
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.RECEIVED_CHANNEL_MEMBER,
|
||||||
|
member: data
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
callTracker[`getChannelMember${channelId}${userId}`] = 0;
|
||||||
|
dispatchError(err, 'getChannelMember');
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUser(userId) {
|
export function getUser(userId) {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export const ActionTypes = keyMirror({
|
|||||||
|
|
||||||
RECEIVED_CHANNELS: null,
|
RECEIVED_CHANNELS: null,
|
||||||
RECEIVED_CHANNEL: null,
|
RECEIVED_CHANNEL: null,
|
||||||
|
RECEIVED_CHANNEL_MEMBER: null,
|
||||||
RECEIVED_MORE_CHANNELS: null,
|
RECEIVED_MORE_CHANNELS: null,
|
||||||
RECEIVED_CHANNEL_STATS: null,
|
RECEIVED_CHANNEL_STATS: null,
|
||||||
RECEIVED_MY_CHANNEL_MEMBERS: null,
|
RECEIVED_MY_CHANNEL_MEMBERS: null,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user