@ermis-network/ermis-chat-sdk 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.browser.cjs +12 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.full-bundle.min.js +11 -11
- package/dist/index.browser.full-bundle.min.js.map +1 -1
- package/dist/index.browser.mjs +12 -5
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +12 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +17 -6
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -1192,11 +1192,13 @@ export class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGen
|
|
|
1192
1192
|
return await this.post<APIResponse>(this.baseURL + `/channels/${channelType}/${channelId}/unpin`);
|
|
1193
1193
|
}
|
|
1194
1194
|
|
|
1195
|
+
channel(type: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
|
|
1196
|
+
channel(type: string, id: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
|
|
1195
1197
|
channel(
|
|
1196
1198
|
channelType: string,
|
|
1197
|
-
|
|
1198
|
-
custom
|
|
1199
|
-
) {
|
|
1199
|
+
channelIDOrCustom?: string | ChannelData<ErmisChatGenerics>,
|
|
1200
|
+
custom?: ChannelData<ErmisChatGenerics>,
|
|
1201
|
+
): Channel<ErmisChatGenerics> {
|
|
1200
1202
|
if (!this.userID) {
|
|
1201
1203
|
throw Error('Call connectUser before creating a channel');
|
|
1202
1204
|
}
|
|
@@ -1205,11 +1207,20 @@ export class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGen
|
|
|
1205
1207
|
throw Error(`Invalid channel group ${channelType}, can't contain the : character`);
|
|
1206
1208
|
}
|
|
1207
1209
|
|
|
1208
|
-
|
|
1210
|
+
let channelID: string | undefined = undefined;
|
|
1211
|
+
let customData = custom || ({} as ChannelData<ErmisChatGenerics>);
|
|
1212
|
+
|
|
1213
|
+
if (typeof channelIDOrCustom === 'string') {
|
|
1214
|
+
channelID = channelIDOrCustom;
|
|
1215
|
+
} else if (typeof channelIDOrCustom === 'object' && channelIDOrCustom !== null) {
|
|
1216
|
+
customData = channelIDOrCustom as ChannelData<ErmisChatGenerics>;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
return this.getChannelById(channelType, channelID, customData);
|
|
1209
1220
|
}
|
|
1210
1221
|
|
|
1211
|
-
getChannelById = (channelType: string, channelID: string, custom: ChannelData<ErmisChatGenerics>) => {
|
|
1212
|
-
const cid = `${channelType}:${channelID}`;
|
|
1222
|
+
getChannelById = (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => {
|
|
1223
|
+
const cid = `${channelType}:${channelID || ''}`;
|
|
1213
1224
|
if (cid in this.activeChannels && !this.activeChannels[cid].disconnected) {
|
|
1214
1225
|
const channel = this.activeChannels[cid];
|
|
1215
1226
|
if (Object.keys(custom).length > 0) {
|