bulbul-chat
Advanced tools
Comparing version 2.5.6 to 2.5.7
@@ -29,3 +29,3 @@ import { ChannelStoragStateType } from './useChannelsData'; | ||
}): Promise<ChatChannel>; | ||
getByExternalId(channelExternalId: string, chatClient: ChatClient, persist: boolean): Promise<ChatChannel>; | ||
getByExternalId(channelExternalId: string, chatClient: ChatClient): Promise<ChatChannel>; | ||
state(): ChannelStoragStateType; | ||
@@ -32,0 +32,0 @@ onUpdate(callback: (data: any) => void): () => void; |
@@ -60,7 +60,10 @@ "use strict"; | ||
for (var i = 0; i < len; i++) { | ||
this.channelsCollection.upsert(channels[i]); | ||
if (channels[i].lastMessage) { | ||
// only upsert unempty channels | ||
this.channelsCollection.upsert(channels[i]); | ||
} | ||
} | ||
}; | ||
ChannelsStorage.prototype.update = function (channel) { | ||
this.channelsCollection.upsert(channel); | ||
this.upsert([channel]); | ||
this.eventRegistry.emit('update', { channel: channel }); | ||
@@ -209,3 +212,3 @@ }; | ||
}; | ||
ChannelsStorage.prototype.getByExternalId = function (channelExternalId, chatClient, persist) { | ||
ChannelsStorage.prototype.getByExternalId = function (channelExternalId, chatClient) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -225,5 +228,3 @@ var doc, channels; | ||
if (channels.length > 0) { | ||
if (persist) { | ||
this.upsert(channels); | ||
} | ||
this.upsert(channels); | ||
return [2 /*return*/, channels[0]]; | ||
@@ -230,0 +231,0 @@ } |
@@ -23,3 +23,3 @@ import ChannelMessageStorage from './ChannelMessageStorage'; | ||
getChannel(channelId: string): Promise<ChatChannel>; | ||
getChannelByExternalId(channelExternalId: string, persist?: boolean): Promise<ChatChannel>; | ||
getChannelByExternalId(channelExternalId: string): Promise<ChatChannel>; | ||
subscribeChannel(channelId: string): CallableFunction; | ||
@@ -26,0 +26,0 @@ subscribeChannelsUpdate(): () => void; |
@@ -268,8 +268,7 @@ "use strict"; | ||
}; | ||
ChatService.prototype.getChannelByExternalId = function (channelExternalId, persist) { | ||
if (persist === void 0) { persist = true; } | ||
ChatService.prototype.getChannelByExternalId = function (channelExternalId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.channelsStorage.getByExternalId(channelExternalId, this.chatClient, persist)]; | ||
case 0: return [4 /*yield*/, this.channelsStorage.getByExternalId(channelExternalId, this.chatClient)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -276,0 +275,0 @@ } |
@@ -118,3 +118,3 @@ "use strict"; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, chatService.getChannelByExternalId(channelExternalId, false)]; | ||
case 0: return [4 /*yield*/, chatService.getChannelByExternalId(channelExternalId)]; | ||
case 1: | ||
@@ -152,3 +152,3 @@ channel = _a.sent(); | ||
chatService | ||
.getChannelByExternalId(channelExternalId, false) | ||
.getChannelByExternalId(channelExternalId) | ||
.then(function (_channel) { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -155,0 +155,0 @@ var currentUser; |
{ | ||
"name": "bulbul-chat", | ||
"version": "2.5.6", | ||
"version": "2.5.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -32,3 +32,6 @@ import { ChannelStoragStateType } from './useChannelsData'; | ||
for (let i = 0; i < len; i++) { | ||
this.channelsCollection.upsert(channels[i]); | ||
if (channels[i].lastMessage) { | ||
// only upsert unempty channels | ||
this.channelsCollection.upsert(channels[i]); | ||
} | ||
} | ||
@@ -38,3 +41,3 @@ } | ||
update(channel: ChatChannel) { | ||
this.channelsCollection.upsert(channel); | ||
this.upsert([channel]); | ||
this.eventRegistry.emit('update', { channel }); | ||
@@ -158,4 +161,3 @@ } | ||
channelExternalId: string, | ||
chatClient: ChatClient, | ||
persist: boolean | ||
chatClient: ChatClient | ||
): Promise<ChatChannel> { | ||
@@ -168,5 +170,3 @@ const doc = this.channelsCollection.findBy({ | ||
if (channels.length > 0) { | ||
if (persist) { | ||
this.upsert(channels); | ||
} | ||
this.upsert(channels); | ||
return channels[0]; | ||
@@ -173,0 +173,0 @@ } |
@@ -219,10 +219,6 @@ import { diffInSeconds } from './utils'; | ||
async getChannelByExternalId( | ||
channelExternalId: string, | ||
persist: boolean = true | ||
) { | ||
async getChannelByExternalId(channelExternalId: string) { | ||
return await this.channelsStorage.getByExternalId( | ||
channelExternalId, | ||
this.chatClient, | ||
persist | ||
this.chatClient | ||
); | ||
@@ -229,0 +225,0 @@ } |
@@ -85,4 +85,3 @@ import { diffInSeconds } from './utils'; | ||
const channel = await chatService.getChannelByExternalId( | ||
channelExternalId, | ||
false | ||
channelExternalId | ||
); | ||
@@ -123,3 +122,3 @@ const channelMessageStorage = chatService.channelMessageStorage( | ||
chatService | ||
.getChannelByExternalId(channelExternalId, false) | ||
.getChannelByExternalId(channelExternalId) | ||
.then(async (_channel) => { | ||
@@ -126,0 +125,0 @@ const currentUser = await chatService.currentUser(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
216786
3952