Этот коммит содержится в:
Christopher Speller
2016-11-11 14:55:05 -05:00
коммит произвёл Harrison Healey
родитель 29efeff095
Коммит ced5f54500
4 изменённых файлов: 80 добавлений и 50 удалений

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

@@ -43,6 +43,9 @@ export function emitChannelClickEvent(channel) {
); );
} }
function switchToChannel(chan) { function switchToChannel(chan) {
const getMyChannelMembersPromise = AsyncClient.getChannelMember(chan.id, UserStore.getCurrentId());
getMyChannelMembersPromise.then(() => {
AsyncClient.getChannelStats(chan.id, true); AsyncClient.getChannelStats(chan.id, true);
AsyncClient.updateLastViewedAt(chan.id); AsyncClient.updateLastViewedAt(chan.id);
loadPosts(chan.id); loadPosts(chan.id);
@@ -54,6 +57,7 @@ export function emitChannelClickEvent(channel) {
id: chan.id, id: chan.id,
prev: ChannelStore.getCurrentId() prev: ChannelStore.getCurrentId()
}); });
});
} }
if (channel.fake) { if (channel.fake) {

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

@@ -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();

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

@@ -111,7 +111,9 @@ export function getChannel(id) {
} }
export function getMyChannelMembers() { export function getMyChannelMembers() {
return new Promise((resolve, reject) => {
if (isCallInProgress('getMyChannelMembers')) { if (isCallInProgress('getMyChannelMembers')) {
resolve();
return; return;
} }
@@ -125,12 +127,15 @@ export function getMyChannelMembers() {
type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS, type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS,
members: data members: data
}); });
resolve();
}, },
(err) => { (err) => {
callTracker.getChannelsUnread = 0; callTracker.getChannelsUnread = 0;
dispatchError(err, 'getMyChannelMembers'); dispatchError(err, 'getMyChannelMembers');
reject();
} }
); );
});
} }
export function updateLastViewedAt(id, active) { export function updateLastViewedAt(id, active) {
@@ -263,7 +268,9 @@ export function getChannelStats(channelId = ChannelStore.getCurrentId(), doVersi
} }
export function getChannelMember(channelId, userId) { export function getChannelMember(channelId, userId) {
return new Promise((resolve, reject) => {
if (isCallInProgress(`getChannelMember${channelId}${userId}`)) { if (isCallInProgress(`getChannelMember${channelId}${userId}`)) {
resolve();
return; return;
} }
@@ -279,12 +286,15 @@ export function getChannelMember(channelId, userId) {
type: ActionTypes.RECEIVED_CHANNEL_MEMBER, type: ActionTypes.RECEIVED_CHANNEL_MEMBER,
member: data member: data
}); });
resolve();
}, },
(err) => { (err) => {
callTracker[`getChannelMember${channelId}${userId}`] = 0; callTracker[`getChannelMember${channelId}${userId}`] = 0;
dispatchError(err, 'getChannelMember'); 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,