New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bulbul-chat

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulbul-chat - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

23

dist/src/ChannelStorage.d.ts
import { ChannelStoragStateType } from './useChannelsData';
import ChatClient, { BlockedUser, ChatChannel } from './ChatClient';
import ChatClient, { ArchivedChannel, BlockedUser, ChatChannel } from './ChatClient';
declare class ChannelsStorage {

@@ -15,2 +15,3 @@ private eventRegistry;

private blackList;
private archivedChannels;
constructor();

@@ -21,3 +22,20 @@ upsert(channels: ChatChannel[]): void;

addLaterChannels(laterChannels: ChatChannel[]): void;
sortedChannels(): ChatChannel[];
sortedChannels(): {
isArchived: boolean;
id: string;
externalId: string;
name: string;
photoUrl: string;
channelType: "direct" | "group";
lastMessage: import("./ChatClient").ChatMessage;
updatedAt: string;
listed: boolean;
watching: boolean;
status: string;
channelMemberships?: import("./ChatClient").ChannelMembership[] | undefined;
lastActivityAt: string;
metadata?: Record<string, unknown> | undefined;
unreadMessageCount?: number | undefined;
isBlockingMe: boolean;
}[];
earliestDate(): string;

@@ -38,4 +56,5 @@ latestDate(): string;

setBlackList(blackList: BlockedUser[]): void;
setArchivedChannels(archivedChannels: ArchivedChannel[]): void;
}
export default ChannelsStorage;
//# sourceMappingURL=ChannelStorage.d.ts.map
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -57,2 +68,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

this.blackList = [];
this.archivedChannels = [];
}

@@ -86,3 +98,6 @@ ChannelsStorage.prototype.upsert = function (channels) {

ChannelsStorage.prototype.sortedChannels = function () {
return this.channelsCollection.sort('lastActivityAt', 'desc');
var _this = this;
return this.channelsCollection
.sort('lastActivityAt', 'desc')
.map(function (channel) { return (__assign(__assign({}, channel), { isArchived: _this.archivedChannels.some(function (ac) { return ac.channelId === channel.id; }) })); });
};

@@ -260,6 +275,9 @@ ChannelsStorage.prototype.earliestDate = function () {

ChannelsStorage.prototype.setBlackList = function (blackList) {
console.log('setBlackList', { blackList: blackList });
this.blackList = blackList;
this.eventRegistry.emit('update', {});
};
ChannelsStorage.prototype.setArchivedChannels = function (archivedChannels) {
this.archivedChannels = archivedChannels;
this.eventRegistry.emit('update', {});
};
return ChannelsStorage;

@@ -266,0 +284,0 @@ }());

@@ -29,2 +29,6 @@ export declare type ChatMessageType = 'plaintext' | 'image' | 'video' | 'audio' | 'document' | 'location' | 'contact' | 'file' | 'url' | 'card';

};
export declare type ArchivedChannel = {
userId: string;
channelId: string;
};
export declare type ChatChannel = {

@@ -46,2 +50,3 @@ id: string;

isBlockingMe: boolean;
isArchived: boolean;
};

@@ -132,2 +137,5 @@ export declare type ChatChannelUpsert = {

isBlockingMe(blockerId: string): Promise<any>;
archiveChannel(channelId: string): Promise<any>;
unArchiveChannel(channelId: string): Promise<any>;
getArchivedChannels(): Promise<ArchivedChannel[]>;
private executeHTTP;

@@ -134,0 +142,0 @@ }

@@ -494,2 +494,23 @@ "use strict";

};
ChatClient.prototype.archiveChannel = function (channelId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.executeHTTP('PUT', "/api/client/chat/channels/archive/" + channelId, {}, {})];
});
});
};
ChatClient.prototype.unArchiveChannel = function (channelId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.executeHTTP('PUT', "/api/client/chat/channels/unarchive/" + channelId, {}, {})];
});
});
};
ChatClient.prototype.getArchivedChannels = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.executeHTTP('GET', '/api/client/chat/channels/archived', {}, {})];
});
});
};
ChatClient.prototype.executeHTTP = function (method, path, urlParams, body) {

@@ -496,0 +517,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -39,2 +39,4 @@ import ChannelMessageStorage from './ChannelMessageStorage';

unBlockUser(blockedId: string): Promise<void>;
archiveChannel(channelId: string): Promise<void>;
unArchiveChannel(channelId: string): Promise<void>;
loadEarlierChannels(): void;

@@ -41,0 +43,0 @@ }

@@ -392,5 +392,15 @@ "use strict";

var _this = this;
var removeOnConnect = this.chatClient.onConnect(function () {
_this.channelsStorage.loadAllLater(_this.chatClient);
});
var removeOnConnect = this.chatClient.onConnect(function () { return __awaiter(_this, void 0, void 0, function () {
var archivedChannels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.chatClient.getArchivedChannels()];
case 1:
archivedChannels = _a.sent();
this.channelsStorage.setArchivedChannels(archivedChannels);
this.channelsStorage.loadAllLater(this.chatClient);
return [2 /*return*/];
}
});
}); });
if (!this.channelsStorage.earliestDate()) {

@@ -591,2 +601,36 @@ this.channelsStorage.loadEarlier(this.chatClient);

};
ChatService.prototype.archiveChannel = function (channelId) {
return __awaiter(this, void 0, void 0, function () {
var archivedChannels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.chatClient.archiveChannel(channelId)];
case 1:
_a.sent();
return [4 /*yield*/, this.chatClient.getArchivedChannels()];
case 2:
archivedChannels = _a.sent();
this.channelsStorage.setArchivedChannels(archivedChannels);
return [2 /*return*/];
}
});
});
};
ChatService.prototype.unArchiveChannel = function (channelId) {
return __awaiter(this, void 0, void 0, function () {
var archivedChannels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.chatClient.unArchiveChannel(channelId)];
case 1:
_a.sent();
return [4 /*yield*/, this.chatClient.getArchivedChannels()];
case 2:
archivedChannels = _a.sent();
this.channelsStorage.setArchivedChannels(archivedChannels);
return [2 /*return*/];
}
});
});
};
ChatService.prototype.loadEarlierChannels = function () {

@@ -593,0 +637,0 @@ this.channelsStorage.loadEarlier(this.chatClient);

2

package.json
{
"name": "bulbul-chat",
"version": "2.6.0",
"version": "2.7.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import { ChannelStoragStateType } from './useChannelsData';
import ChatClient, { BlockedUser, ChatChannel } from './ChatClient';
import ChatClient, {
ArchivedChannel,
BlockedUser,
ChatChannel,
} from './ChatClient';
import EventRegistry from './EventRegistry';

@@ -19,2 +23,3 @@ import InMemoryCollection from './InMemoryCollection';

private blackList: BlockedUser[];
private archivedChannels: ArchivedChannel[];

@@ -30,2 +35,3 @@ constructor() {

this.blackList = [];
this.archivedChannels = [];
}

@@ -63,3 +69,10 @@

sortedChannels() {
return this.channelsCollection.sort('lastActivityAt', 'desc');
return this.channelsCollection
.sort('lastActivityAt', 'desc')
.map((channel) => ({
...channel,
isArchived: this.archivedChannels.some(
(ac) => ac.channelId === channel.id
),
}));
}

@@ -205,8 +218,12 @@

setBlackList(blackList: BlockedUser[]) {
console.log('setBlackList', { blackList });
this.blackList = blackList;
this.eventRegistry.emit('update', {});
}
setArchivedChannels(archivedChannels: ArchivedChannel[]) {
this.archivedChannels = archivedChannels;
this.eventRegistry.emit('update', {});
}
}
export default ChannelsStorage;

@@ -49,2 +49,7 @@ import * as qs from 'qs';

export type ArchivedChannel = {
userId: string;
channelId: string;
};
export type ChatChannel = {

@@ -66,2 +71,3 @@ id: string;

isBlockingMe: boolean;
isArchived: boolean;
};

@@ -585,2 +591,29 @@

async archiveChannel(channelId: string) {
return this.executeHTTP(
'PUT',
`/api/client/chat/channels/archive/${channelId}`,
{},
{}
);
}
async unArchiveChannel(channelId: string) {
return this.executeHTTP(
'PUT',
`/api/client/chat/channels/unarchive/${channelId}`,
{},
{}
);
}
async getArchivedChannels(): Promise<ArchivedChannel[]> {
return this.executeHTTP(
'GET',
'/api/client/chat/channels/archived',
{},
{}
);
}
private async executeHTTP(

@@ -587,0 +620,0 @@ method: 'GET' | 'POST' | 'PUT',

@@ -343,3 +343,6 @@ import { diffInSeconds } from './utils';

subscribeChannelsUpdate(): () => void {
const removeOnConnect = this.chatClient.onConnect(() => {
const removeOnConnect = this.chatClient.onConnect(async () => {
// update archived channels list with latest
const archivedChannels = await this.chatClient.getArchivedChannels();
this.channelsStorage.setArchivedChannels(archivedChannels);
this.channelsStorage.loadAllLater(this.chatClient);

@@ -510,2 +513,14 @@ });

async archiveChannel(channelId: string) {
await this.chatClient.archiveChannel(channelId);
const archivedChannels = await this.chatClient.getArchivedChannels();
this.channelsStorage.setArchivedChannels(archivedChannels);
}
async unArchiveChannel(channelId: string) {
await this.chatClient.unArchiveChannel(channelId);
const archivedChannels = await this.chatClient.getArchivedChannels();
this.channelsStorage.setArchivedChannels(archivedChannels);
}
loadEarlierChannels() {

@@ -512,0 +527,0 @@ this.channelsStorage.loadEarlier(this.chatClient);

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc