bulbul-chat
Advanced tools
Comparing version 2.4.4 to 2.5.0
@@ -6,1 +6,2 @@ import ChatService from './src/ChatService'; | ||
export { ChatService, useChannelData, useChannelsData, ChatUser, ChatChannel, ChatMessage, IActingType, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -13,1 +13,2 @@ "use strict"; | ||
Object.defineProperty(exports, "useChannelsData", { enumerable: true, get: function () { return useChannelsData_1.useChannelsData; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -32,1 +32,2 @@ import { ChannelMessageStorageStateType } from './useChannelData'; | ||
export default ChannelMessageStorage; | ||
//# sourceMappingURL=ChannelMessageStorage.d.ts.map |
@@ -265,1 +265,2 @@ "use strict"; | ||
exports.default = ChannelMessageStorage; | ||
//# sourceMappingURL=ChannelMessageStorage.js.map |
@@ -33,1 +33,2 @@ import { ChannelStoragStateType } from './useChannelsData'; | ||
export default ChannelsStorage; | ||
//# sourceMappingURL=ChannelStorage.d.ts.map |
@@ -108,2 +108,3 @@ "use strict"; | ||
} | ||
// TODO setLastRecievedMessageId(channelX.channelId, channelX.lastMessage.id) | ||
_this.errorMessage = undefined; | ||
@@ -125,3 +126,3 @@ _this.initialDataLoaded = true; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var laterMessages, error_1; | ||
var laterChannels, error_1; | ||
return __generator(this, function (_a) { | ||
@@ -137,7 +138,8 @@ switch (_a.label) { | ||
case 2: | ||
laterMessages = _a.sent(); | ||
laterChannels = _a.sent(); | ||
// TODO setLastRecievedMessageId(channelX.channelId, channelX.lastMessage.id) | ||
this.loadingLater = false; | ||
this.addLaterChannels(laterMessages); | ||
this.addLaterChannels(laterChannels); | ||
this.eventRegistry.emit('update', {}); | ||
return [2 /*return*/, laterMessages]; | ||
return [2 /*return*/, laterChannels]; | ||
case 3: | ||
@@ -252,1 +254,2 @@ error_1 = _a.sent(); | ||
exports.default = ChannelsStorage; | ||
//# sourceMappingURL=ChannelStorage.js.map |
@@ -22,2 +22,3 @@ export declare type ChatMessageType = 'plaintext' | 'image' | 'video' | 'audio' | 'document' | 'location' | 'contact' | 'file' | 'url' | 'card'; | ||
lastReadMessageId?: number | null; | ||
lastRecievedMessageId?: number | null; | ||
user: ChatUser; | ||
@@ -44,2 +45,3 @@ }; | ||
channelMembership?: ChannelMembership; | ||
channelMemberships?: ChannelMembership[]; | ||
}; | ||
@@ -118,1 +120,2 @@ export declare type ChatMessage = { | ||
export default ChatClient; | ||
//# sourceMappingURL=ChatClient.d.ts.map |
@@ -492,1 +492,2 @@ "use strict"; | ||
exports.default = ChatClient; | ||
//# sourceMappingURL=ChatClient.js.map |
@@ -7,1 +7,2 @@ import ChannelMessageStorage from './ChannelMessageStorage'; | ||
export default ChatMemoryStorageAdapter; | ||
//# sourceMappingURL=ChatMemoryStorageAdapter.d.ts.map |
@@ -20,1 +20,2 @@ "use strict"; | ||
exports.default = ChatMemoryStorageAdapter; | ||
//# sourceMappingURL=ChatMemoryStorageAdapter.js.map |
@@ -40,1 +40,2 @@ import ChannelMessageStorage from './ChannelMessageStorage'; | ||
export default ChatService; | ||
//# sourceMappingURL=ChatService.d.ts.map |
@@ -96,3 +96,3 @@ "use strict"; | ||
this.chatClient.onChannelUpdate(function (channel) { return __awaiter(_this, void 0, void 0, function () { | ||
var currentUser, updatedChannel; | ||
var currentUser, oldChannel, updatedChannel; | ||
var _a, _b; | ||
@@ -102,18 +102,21 @@ return __generator(this, function (_c) { | ||
case 0: | ||
if (!channel) return [3 /*break*/, 4]; | ||
if (!channel) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.currentUser()]; | ||
case 1: | ||
currentUser = _c.sent(); | ||
updatedChannel = __assign({}, channel); | ||
return [4 /*yield*/, this.channelsStorage.get(channel.id, this.chatClient)]; | ||
case 2: | ||
oldChannel = _c.sent(); | ||
updatedChannel = __assign(__assign({}, oldChannel), channel); | ||
if (!(((_a = this.currentActiveChannel) === null || _a === void 0 ? void 0 : _a.id) !== channel.id && | ||
((_b = channel.lastMessage) === null || _b === void 0 ? void 0 : _b.senderId) !== currentUser.id)) return [3 /*break*/, 3]; | ||
((_b = channel.lastMessage) === null || _b === void 0 ? void 0 : _b.senderId) !== currentUser.id)) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.chatClient.getUnreadMessageCount(channel)]; | ||
case 2: | ||
case 3: | ||
// if the channel is open then mark this message as read | ||
updatedChannel = _c.sent(); | ||
_c.label = 3; | ||
case 3: | ||
_c.label = 4; | ||
case 4: | ||
this.channelsStorage.update(updatedChannel); | ||
_c.label = 4; | ||
case 4: return [2 /*return*/]; | ||
_c.label = 5; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -123,11 +126,19 @@ }); | ||
this.chatClient.onChannelUpsert(function (data) { return __awaiter(_this, void 0, void 0, function () { | ||
var channel, _a, channelMembership, rest, nChannel; | ||
var _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var channel, _a, channelMembership, channelMemberships, rest, nChannel; | ||
var _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: return [4 /*yield*/, this.channelsStorage.get(data.channelId, this.chatClient)]; | ||
case 1: | ||
channel = _c.sent(); | ||
_a = data.upsert, channelMembership = _a.channelMembership, rest = __rest(_a, ["channelMembership"]); | ||
nChannel = __assign(__assign(__assign({}, channel), rest), { channelMemberships: (_b = channel.channelMemberships) === null || _b === void 0 ? void 0 : _b.map(function (cm) { | ||
channel = _d.sent(); | ||
_a = data.upsert, channelMembership = _a.channelMembership, channelMemberships = _a.channelMemberships, rest = __rest(_a, ["channelMembership", "channelMemberships"]); | ||
nChannel = __assign(__assign({}, channel), rest); | ||
if (channelMemberships) { | ||
nChannel.channelMemberships = (_b = channel.channelMemberships) === null || _b === void 0 ? void 0 : _b.map(function (cm) { | ||
var nChannelMembership = channelMemberships.find(function (cm2) { return cm2.id === cm.id; }); | ||
return __assign(__assign({}, cm), nChannelMembership); | ||
}); | ||
} | ||
if (channelMembership) { | ||
nChannel.channelMemberships = (_c = channel.channelMemberships) === null || _c === void 0 ? void 0 : _c.map(function (cm) { | ||
if (cm.id === (channelMembership === null || channelMembership === void 0 ? void 0 : channelMembership.id)) { | ||
@@ -137,3 +148,4 @@ return __assign({}, channelMembership); | ||
return cm; | ||
}) }); | ||
}); | ||
} | ||
this.channelsStorage.update(nChannel); | ||
@@ -312,2 +324,3 @@ return [2 /*return*/]; | ||
channelMessageStorage.addLiveMessage([message]); | ||
// TODO setLastRecievedMessageId(channelId, message.id) | ||
if (message.senderId !== currentUser.id && | ||
@@ -510,1 +523,2 @@ channelId === ((_a = _this.currentActiveChannel) === null || _a === void 0 ? void 0 : _a.id)) { | ||
exports.default = ChatService; | ||
//# sourceMappingURL=ChatService.js.map |
@@ -10,1 +10,2 @@ declare type Callback = (data: any) => void; | ||
export default EventRegistry; | ||
//# sourceMappingURL=EventRegistry.d.ts.map |
@@ -29,1 +29,2 @@ "use strict"; | ||
exports.default = EventRegistry; | ||
//# sourceMappingURL=EventRegistry.js.map |
@@ -13,1 +13,2 @@ declare type ItemConstraint = Record<string, any>; | ||
export default InMemoryCollection; | ||
//# sourceMappingURL=InMemoryCollection.d.ts.map |
@@ -41,1 +41,2 @@ "use strict"; | ||
exports.default = InMemoryCollection; | ||
//# sourceMappingURL=InMemoryCollection.js.map |
@@ -19,1 +19,2 @@ import { ChatMessage, ChatChannel, ChatUser, IActingType } from './ChatClient'; | ||
export {}; | ||
//# sourceMappingURL=useChannelData.d.ts.map |
@@ -238,1 +238,2 @@ "use strict"; | ||
exports.useChannelData = useChannelData; | ||
//# sourceMappingURL=useChannelData.js.map |
@@ -13,1 +13,2 @@ import { ChatChannel } from './ChatClient'; | ||
export declare const useChannelsData: (chatService?: ChatService | undefined) => [ChannelStoragStateType, () => void]; | ||
//# sourceMappingURL=useChannelsData.d.ts.map |
@@ -84,1 +84,2 @@ "use strict"; | ||
exports.useChannelsData = useChannelsData; | ||
//# sourceMappingURL=useChannelsData.js.map |
export declare const diffInSeconds: (d1: Date | string, d2: Date | string) => number; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -14,1 +14,2 @@ "use strict"; | ||
exports.diffInSeconds = diffInSeconds; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "bulbul-chat", | ||
"version": "2.4.4", | ||
"version": "2.5.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -82,2 +82,3 @@ import { ChannelStoragStateType } from './useChannelsData'; | ||
} | ||
// TODO setLastRecievedMessageId(channelX.channelId, channelX.lastMessage.id) | ||
this.errorMessage = undefined; | ||
@@ -102,10 +103,11 @@ this.initialDataLoaded = true; | ||
try { | ||
const laterMessages = await chatClient.loadLaterChannels( | ||
const laterChannels = await chatClient.loadLaterChannels( | ||
this.latestDate(), | ||
maxSize | ||
); | ||
// TODO setLastRecievedMessageId(channelX.channelId, channelX.lastMessage.id) | ||
this.loadingLater = false; | ||
this.addLaterChannels(laterMessages); | ||
this.addLaterChannels(laterChannels); | ||
this.eventRegistry.emit('update', {}); | ||
return laterMessages; | ||
return laterChannels; | ||
} catch (error) { | ||
@@ -112,0 +114,0 @@ this.loadingLater = false; |
@@ -40,2 +40,3 @@ import * as qs from 'qs'; | ||
lastReadMessageId?: number | null; | ||
lastRecievedMessageId?: number | null; | ||
user: ChatUser; | ||
@@ -64,2 +65,3 @@ }; | ||
channelMembership?: ChannelMembership; | ||
channelMemberships?: ChannelMembership[]; | ||
}; | ||
@@ -66,0 +68,0 @@ |
@@ -70,3 +70,7 @@ import { diffInSeconds } from './utils'; | ||
const currentUser = await this.currentUser(); | ||
let updatedChannel = { ...channel }; | ||
const oldChannel = await this.channelsStorage.get( | ||
channel.id, | ||
this.chatClient | ||
); | ||
let updatedChannel = { ...oldChannel, ...channel }; | ||
if ( | ||
@@ -88,7 +92,17 @@ this.currentActiveChannel?.id !== channel.id && | ||
); | ||
const { channelMembership, ...rest } = data.upsert; | ||
const { channelMembership, channelMemberships, ...rest } = data.upsert; | ||
const nChannel: ChatChannel = { | ||
...channel, | ||
...rest, | ||
channelMemberships: channel.channelMemberships?.map((cm) => { | ||
}; | ||
if (channelMemberships) { | ||
nChannel.channelMemberships = channel.channelMemberships?.map((cm) => { | ||
const nChannelMembership = channelMemberships.find( | ||
(cm2) => cm2.id === cm.id | ||
); | ||
return { ...cm, ...nChannelMembership }; | ||
}); | ||
} | ||
if (channelMembership) { | ||
nChannel.channelMemberships = channel.channelMemberships?.map((cm) => { | ||
if (cm.id === channelMembership?.id) { | ||
@@ -98,4 +112,4 @@ return { ...channelMembership }; | ||
return cm; | ||
}), | ||
}; | ||
}); | ||
} | ||
this.channelsStorage.update(nChannel); | ||
@@ -263,2 +277,4 @@ }); | ||
channelMessageStorage.addLiveMessage([message]); | ||
// TODO setLastRecievedMessageId(channelId, message.id) | ||
if ( | ||
@@ -265,0 +281,0 @@ message.senderId !== currentUser.id && |
@@ -5,4 +5,4 @@ { | ||
// "incremental": true, /* Enable incremental compilation */ | ||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | ||
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, | ||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, | ||
// "lib": [], /* Specify library files to be included in the compilation. */ | ||
@@ -13,6 +13,6 @@ // "allowJs": true, /* Allow javascript files to be compiled. */ | ||
"declaration": true, | ||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ | ||
// "sourceMap": true, /* Generates corresponding '.map' file. */ | ||
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */, | ||
"sourceMap": true /* Generates corresponding '.map' file. */, | ||
// "outFile": "./", /* Concatenate and emit output to single file. */ | ||
"outDir": "dist", /* Redirect output structure to the directory. */ | ||
"outDir": "dist" /* Redirect output structure to the directory. */, | ||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | ||
@@ -28,4 +28,4 @@ // "composite": true, /* Enable project compilation */ | ||
/* Strict Type-Checking Options */ | ||
"strict": true, /* Enable all strict type-checking options. */ | ||
"strict": true /* Enable all strict type-checking options. */, | ||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ | ||
@@ -53,3 +53,3 @@ // "strictNullChecks": true, /* Enable strict null checks. */ | ||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ | ||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | ||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, | ||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ | ||
@@ -69,4 +69,4 @@ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ | ||
/* Advanced Options */ | ||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ | ||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ | ||
} | ||
} |
214281
3897