bulbul-chat
Advanced tools
Comparing version 2.3.1 to 2.3.2
@@ -98,3 +98,3 @@ export declare type ChatMessageType = 'plaintext' | 'image' | 'video' | 'audio' | 'document' | 'location' | 'file' | 'url' | 'card'; | ||
onChannelDelete(callback: (channel: ChatChannel) => void): () => void; | ||
emitMarkAllAsRead(channelId: string): Promise<void>; | ||
emitMarkReadUntil(channelId: string, messageId?: string): Promise<void>; | ||
getUnreadMessageCount(channel: ChatChannel): Promise<ChatChannel>; | ||
@@ -101,0 +101,0 @@ loadEarlierChannels(earliestDate?: string, size?: number): Promise<ChatChannel[]>; |
@@ -231,13 +231,13 @@ "use strict"; | ||
}; | ||
ChatClient.prototype.emitMarkAllAsRead = function (channelId) { | ||
ChatClient.prototype.emitMarkReadUntil = function (channelId, messageId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
this.socket.emit('markAllAsRead', channelId, function (data) { | ||
this.socket.emit('markReadUntil', { channelId: channelId, messageId: messageId }, function (data) { | ||
var upsert = { | ||
unreadMessageCount: 0, | ||
unreadMessageCount: data.unreadMessageCount, | ||
channelMembership: data.updatedChannelMembership, | ||
}; | ||
_this.eventRegistry.emit('channelUpsert', { | ||
channelId: data.channelId, | ||
channelId: channelId, | ||
upsert: upsert, | ||
@@ -244,0 +244,0 @@ }); |
@@ -86,3 +86,5 @@ "use strict"; | ||
channelMessageStorage = this.channelMessageStorage(message.channelId); | ||
channelMessageStorage.addLiveMessage([message]); | ||
if (channelMessageStorage.initialMessagesLoaded) { | ||
channelMessageStorage.addLiveMessage([message]); | ||
} | ||
return [4 /*yield*/, this.currentUser()]; | ||
@@ -373,3 +375,3 @@ case 1: | ||
ChatService.prototype.markAllAsRead = function (channelId) { | ||
this.chatClient.emitMarkAllAsRead(channelId); | ||
this.chatClient.emitMarkReadUntil(channelId); | ||
}; | ||
@@ -376,0 +378,0 @@ ChatService.prototype.sendAttachment = function (channelId, messageType, content, file) { |
@@ -68,7 +68,2 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -131,6 +126,3 @@ exports.useChannelData = void 0; | ||
unsubscribeChannel = chatService.subscribeChannel(channel.id); | ||
setCurrentUnsubscriptions(__spreadArray(__spreadArray([], currentUnsubscriptions), [ | ||
removeListener, | ||
unsubscribeChannel, | ||
])); | ||
setCurrentUnsubscriptions([removeListener, unsubscribeChannel]); | ||
return [2 /*return*/]; | ||
@@ -143,2 +135,4 @@ } | ||
currentUnsubscriptions.length === 0) { | ||
// unsubscribe from previous channels | ||
currentUnsubscriptions.forEach(function (cb) { return cb(); }); | ||
subscribeToChannel(); | ||
@@ -145,0 +139,0 @@ } |
{ | ||
"name": "bulbul-chat", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -312,13 +312,13 @@ import * as qs from 'qs'; | ||
async emitMarkAllAsRead(channelId: string) { | ||
async emitMarkReadUntil(channelId: string, messageId?: string) { | ||
this.socket.emit( | ||
'markAllAsRead', | ||
channelId, | ||
(data: { updatedChannelMembership: any; channelId: string }) => { | ||
'markReadUntil', | ||
{ channelId, messageId }, | ||
(data: { updatedChannelMembership: any; unreadMessageCount: number }) => { | ||
const upsert: ChatChannelUpsert = { | ||
unreadMessageCount: 0, | ||
unreadMessageCount: data.unreadMessageCount, | ||
channelMembership: data.updatedChannelMembership, | ||
}; | ||
this.eventRegistry.emit('channelUpsert', { | ||
channelId: data.channelId, | ||
channelId, | ||
upsert, | ||
@@ -325,0 +325,0 @@ }); |
@@ -53,3 +53,5 @@ import { diffInSeconds } from './utils'; | ||
); | ||
channelMessageStorage.addLiveMessage([message]); | ||
if (channelMessageStorage.initialMessagesLoaded) { | ||
channelMessageStorage.addLiveMessage([message]); | ||
} | ||
const currentUser = await this.currentUser(); | ||
@@ -325,3 +327,3 @@ if (message.channelId !== this.currentChannel?.id) { | ||
markAllAsRead(channelId: string) { | ||
this.chatClient.emitMarkAllAsRead(channelId); | ||
this.chatClient.emitMarkReadUntil(channelId); | ||
} | ||
@@ -328,0 +330,0 @@ |
@@ -92,7 +92,3 @@ import { diffInSeconds } from './utils'; | ||
const unsubscribeChannel = chatService.subscribeChannel(channel.id); | ||
setCurrentUnsubscriptions([ | ||
...currentUnsubscriptions, | ||
removeListener, | ||
unsubscribeChannel, | ||
]); | ||
setCurrentUnsubscriptions([removeListener, unsubscribeChannel]); | ||
} | ||
@@ -104,2 +100,4 @@ | ||
) { | ||
// unsubscribe from previous channels | ||
currentUnsubscriptions.forEach((cb) => cb()); | ||
subscribeToChannel(); | ||
@@ -106,0 +104,0 @@ } |
143863
3511