add helper method to add ephemeral messages; also switch 'delete message' to this new method

Этот коммит содержится в:
Florian Orben
2015-12-04 20:18:49 +01:00
родитель 985dc06e5f
Коммит 99d79eee56
5 изменённых файлов: 104 добавлений и 49 удалений

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

@@ -82,7 +82,7 @@ export function getChannels(checkVersion) {
);
}
export function getChannel(id) {
export function getChannelAndAddUnreadMessages(id, unreadCount) {
if (isCallInProgress('getChannel' + id)) {
return;
}
@@ -97,6 +97,7 @@ export function getChannel(id) {
return;
}
data.channel.total_msg_count += (unreadCount || 0);
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_CHANNEL,
channel: data.channel,
@@ -110,6 +111,10 @@ export function getChannel(id) {
);
}
export function getChannel(id) {
getChannelAndAddUnreadMessages(id, 0);
}
export function updateLastViewedAt(id) {
let channelId;
if (id) {
@@ -131,6 +136,14 @@ export function updateLastViewedAt(id) {
channelId,
() => {
callTracker.updateLastViewed = 0;
var channel = ChannelStore.get(channelId);
var member = ChannelStore.getMember(channelId);
if (channel && member) {
member.msg_count = channel.total_msg_count;
member.last_viewed_at = utils.getTimestamp();
ChannelStore.setChannelMember(member);
}
},
(err) => {
callTracker.updateLastViewed = 0;

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

@@ -1254,3 +1254,8 @@ export function isFeatureEnabled(feature) {
export function isSystemMessage(post) {
return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0);
}
// convenience method to dispatch an event in JS' next event cycle
export function defer(fn) {
setTimeout(fn, 0);
}