stream-chat 5.2.0 → 5.3.0
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/dist/browser.es.js +280 -231
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +280 -231
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +280 -231
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +280 -231
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +7 -4
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +26 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/types.d.ts +15 -7
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +11 -4
- package/src/channel_state.ts +6 -1
- package/src/client.ts +21 -2
- package/src/types.ts +16 -7
package/src/channel.ts
CHANGED
|
@@ -1260,6 +1260,7 @@ export class Channel<
|
|
|
1260
1260
|
// because in client.ts the handleEvent call that flows to this sets this `event.received_at = new Date();`
|
|
1261
1261
|
last_read: event.received_at as Date,
|
|
1262
1262
|
user: event.user,
|
|
1263
|
+
unread_messages: 0,
|
|
1263
1264
|
};
|
|
1264
1265
|
|
|
1265
1266
|
if (event.user?.id === this.getClient().user?.id) {
|
|
@@ -1308,6 +1309,7 @@ export class Channel<
|
|
|
1308
1309
|
channelState.read[event.user.id] = {
|
|
1309
1310
|
last_read: new Date(event.created_at as string),
|
|
1310
1311
|
user: event.user,
|
|
1312
|
+
unread_messages: 0,
|
|
1311
1313
|
};
|
|
1312
1314
|
} else if (this._countMessageAsUnread(event.message)) {
|
|
1313
1315
|
channelState.unreadCount = channelState.unreadCount + 1;
|
|
@@ -1472,6 +1474,7 @@ export class Channel<
|
|
|
1472
1474
|
this.state.read[user.id] = {
|
|
1473
1475
|
user,
|
|
1474
1476
|
last_read,
|
|
1477
|
+
unread_messages: 0,
|
|
1475
1478
|
};
|
|
1476
1479
|
}
|
|
1477
1480
|
}
|
|
@@ -1479,10 +1482,14 @@ export class Channel<
|
|
|
1479
1482
|
// apply read state if part of the state
|
|
1480
1483
|
if (state.read) {
|
|
1481
1484
|
for (const read of state.read) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1485
|
+
this.state.read[read.user.id] = {
|
|
1486
|
+
last_read: new Date(read.last_read),
|
|
1487
|
+
unread_messages: read.unread_messages ?? 0,
|
|
1488
|
+
user: read.user,
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
if (read.user.id === user?.id) {
|
|
1492
|
+
this.state.unreadCount = this.state.read[read.user.id].unread_messages;
|
|
1486
1493
|
}
|
|
1487
1494
|
}
|
|
1488
1495
|
}
|
package/src/channel_state.ts
CHANGED
|
@@ -11,6 +11,11 @@ import {
|
|
|
11
11
|
UserResponse,
|
|
12
12
|
} from './types';
|
|
13
13
|
|
|
14
|
+
type ChannelReadStatus<UserType> = Record<
|
|
15
|
+
string,
|
|
16
|
+
{ last_read: Date; unread_messages: number; user: UserResponse<UserType> }
|
|
17
|
+
>;
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* ChannelState - A container class for the channel state.
|
|
16
21
|
*/
|
|
@@ -29,7 +34,7 @@ export class ChannelState<
|
|
|
29
34
|
string,
|
|
30
35
|
Event<AttachmentType, ChannelType, CommandType, EventType, MessageType, ReactionType, UserType>
|
|
31
36
|
>;
|
|
32
|
-
read:
|
|
37
|
+
read: ChannelReadStatus<UserType>;
|
|
33
38
|
messages: Array<
|
|
34
39
|
ReturnType<
|
|
35
40
|
ChannelState<
|
package/src/client.ts
CHANGED
|
@@ -699,7 +699,6 @@ export class StreamChat<
|
|
|
699
699
|
apnTemplate: '{}', //if app doesn't have apn configured it will error
|
|
700
700
|
firebaseTemplate: '{}', //if app doesn't have firebase configured it will error
|
|
701
701
|
firebaseDataTemplate: '{}', //if app doesn't have firebase configured it will error
|
|
702
|
-
huaweiDataTemplate: '{}' //if app doesn't have huawei configured it will error
|
|
703
702
|
skipDevices: true, // skip config/device checks and sending to real devices
|
|
704
703
|
}
|
|
705
704
|
*/
|
|
@@ -710,7 +709,6 @@ export class StreamChat<
|
|
|
710
709
|
...(data.apnTemplate ? { apn_template: data.apnTemplate } : {}),
|
|
711
710
|
...(data.firebaseTemplate ? { firebase_template: data.firebaseTemplate } : {}),
|
|
712
711
|
...(data.firebaseDataTemplate ? { firebase_data_template: data.firebaseDataTemplate } : {}),
|
|
713
|
-
...(data.huaweiDataTemplate ? { huawei_data_template: data.huaweiDataTemplate } : {}),
|
|
714
712
|
...(data.skipDevices ? { skip_devices: true } : {}),
|
|
715
713
|
});
|
|
716
714
|
}
|
|
@@ -2267,6 +2265,7 @@ export class StreamChat<
|
|
|
2267
2265
|
* It is present for internal usage only.
|
|
2268
2266
|
* This function can, and will, break and/or be removed at any point in time.
|
|
2269
2267
|
*
|
|
2268
|
+
* @private
|
|
2270
2269
|
* @param {FlagReportsFilters} filterConditions MongoDB style filter conditions
|
|
2271
2270
|
* @param {FlagReportsPaginationOptions} options Option object, {limit: 10, offset:0}
|
|
2272
2271
|
*
|
|
@@ -2290,6 +2289,7 @@ export class StreamChat<
|
|
|
2290
2289
|
* It is present for internal usage only.
|
|
2291
2290
|
* This function can, and will, break and/or be removed at any point in time.
|
|
2292
2291
|
*
|
|
2292
|
+
* @private
|
|
2293
2293
|
* @param {string} [id] flag report to review
|
|
2294
2294
|
* @param {string} [reviewResult] flag report review result
|
|
2295
2295
|
* @param {string} [options.user_id] currentUserID, only used with serverside auth
|
|
@@ -2303,6 +2303,25 @@ export class StreamChat<
|
|
|
2303
2303
|
});
|
|
2304
2304
|
}
|
|
2305
2305
|
|
|
2306
|
+
/**
|
|
2307
|
+
* _unblockMessage - unblocks message blocked by automod
|
|
2308
|
+
*
|
|
2309
|
+
* Note: Do not use this.
|
|
2310
|
+
* It is present for internal usage only.
|
|
2311
|
+
* This function can, and will, break and/or be removed at any point in time.
|
|
2312
|
+
*
|
|
2313
|
+
* @private
|
|
2314
|
+
* @param {string} targetMessageID
|
|
2315
|
+
* @param {string} [options.user_id] currentUserID, only used with serverside auth
|
|
2316
|
+
* @returns {Promise<APIResponse>}
|
|
2317
|
+
*/
|
|
2318
|
+
async _unblockMessage(targetMessageID: string, options: { user_id?: string } = {}) {
|
|
2319
|
+
return await this.post<APIResponse>(this.baseURL + '/moderation/unblock_message', {
|
|
2320
|
+
target_message_id: targetMessageID,
|
|
2321
|
+
...options,
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2306
2325
|
/**
|
|
2307
2326
|
* @deprecated use markChannelsRead instead
|
|
2308
2327
|
*
|
package/src/types.ts
CHANGED
|
@@ -99,6 +99,7 @@ export type AppSettingsAPIResponse<CommandType extends string = LiteralStringFor
|
|
|
99
99
|
apn?: APNConfig;
|
|
100
100
|
firebase?: FirebaseConfig;
|
|
101
101
|
huawei?: HuaweiConfig;
|
|
102
|
+
xiaomi?: XiaomiConfig;
|
|
102
103
|
};
|
|
103
104
|
revoke_tokens_issued_before?: string | null;
|
|
104
105
|
search_backend?: 'disabled' | 'elasticsearch' | 'postgres';
|
|
@@ -286,13 +287,16 @@ export type ChannelMemberResponse<UserType = UR> = {
|
|
|
286
287
|
|
|
287
288
|
export type CheckPushResponse = APIResponse & {
|
|
288
289
|
device_errors?: {
|
|
289
|
-
|
|
290
|
-
|
|
290
|
+
[deviceID: string]: {
|
|
291
|
+
error_message?: string;
|
|
292
|
+
provider?: string;
|
|
293
|
+
};
|
|
291
294
|
};
|
|
292
295
|
general_errors?: string[];
|
|
293
296
|
rendered_apn_template?: string;
|
|
294
297
|
rendered_firebase_template?: string;
|
|
295
|
-
|
|
298
|
+
rendered_message?: {};
|
|
299
|
+
skip_devides?: boolean;
|
|
296
300
|
};
|
|
297
301
|
|
|
298
302
|
export type CheckSQSResponse = APIResponse & {
|
|
@@ -1443,7 +1447,6 @@ export type AppSettings = {
|
|
|
1443
1447
|
huawei_config?: {
|
|
1444
1448
|
id: string;
|
|
1445
1449
|
secret: string;
|
|
1446
|
-
data_template?: string;
|
|
1447
1450
|
};
|
|
1448
1451
|
image_moderation_enabled?: boolean;
|
|
1449
1452
|
image_upload_config?: FileUploadConfig;
|
|
@@ -1457,6 +1460,10 @@ export type AppSettings = {
|
|
|
1457
1460
|
sqs_url?: string;
|
|
1458
1461
|
webhook_events?: Array<string> | null;
|
|
1459
1462
|
webhook_url?: string;
|
|
1463
|
+
xiaomi_config?: {
|
|
1464
|
+
package_name: string;
|
|
1465
|
+
secret: string;
|
|
1466
|
+
};
|
|
1460
1467
|
};
|
|
1461
1468
|
|
|
1462
1469
|
export type Attachment<T = UR> = T & {
|
|
@@ -1588,7 +1595,7 @@ export type CheckPushInput<UserType = UR> = {
|
|
|
1588
1595
|
user_id?: string;
|
|
1589
1596
|
};
|
|
1590
1597
|
|
|
1591
|
-
export type PushProvider = 'apn' | 'firebase' | 'huawei';
|
|
1598
|
+
export type PushProvider = 'apn' | 'firebase' | 'huawei' | 'xiaomi';
|
|
1592
1599
|
|
|
1593
1600
|
export type CommandVariants<CommandType extends string = LiteralStringForUnion> =
|
|
1594
1601
|
| 'all'
|
|
@@ -1765,7 +1772,10 @@ export type FirebaseConfig = {
|
|
|
1765
1772
|
};
|
|
1766
1773
|
|
|
1767
1774
|
export type HuaweiConfig = {
|
|
1768
|
-
|
|
1775
|
+
enabled?: boolean;
|
|
1776
|
+
};
|
|
1777
|
+
|
|
1778
|
+
export type XiaomiConfig = {
|
|
1769
1779
|
enabled?: boolean;
|
|
1770
1780
|
};
|
|
1771
1781
|
|
|
@@ -1926,7 +1936,6 @@ export type TestPushDataInput = {
|
|
|
1926
1936
|
apnTemplate?: string;
|
|
1927
1937
|
firebaseDataTemplate?: string;
|
|
1928
1938
|
firebaseTemplate?: string;
|
|
1929
|
-
huaweiDataTemplate?: string;
|
|
1930
1939
|
messageID?: string;
|
|
1931
1940
|
skipDevices?: boolean;
|
|
1932
1941
|
};
|