stream-chat 9.52.0 → 9.53.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/cjs/index.browser.js +108 -48
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +108 -48
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +108 -48
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/channel.d.ts +4 -2
- package/dist/types/channel_batch_updater.d.ts +9 -2
- package/dist/types/client.d.ts +17 -0
- package/dist/types/types.d.ts +33 -0
- package/dist/types/utils.d.ts +9 -5
- package/package.json +1 -1
- package/src/channel.ts +26 -18
- package/src/channel_batch_updater.ts +28 -2
- package/src/client.ts +94 -23
- package/src/messageDelivery/MessageDeliveryReporter.ts +5 -4
- package/src/types.ts +37 -0
- package/src/utils.ts +30 -7
package/src/utils.ts
CHANGED
|
@@ -41,6 +41,36 @@ export function logChatPromiseExecution<T>(promise: Promise<T>, name: string) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The default no-op client logger.
|
|
46
|
+
*/
|
|
47
|
+
export const noopLogger: Logger = () => null;
|
|
48
|
+
|
|
49
|
+
const logError = <T>(logger: Logger, error: unknown, event: T) => {
|
|
50
|
+
const message = 'Unhandled error in event listener';
|
|
51
|
+
logger('error', message, { error, event });
|
|
52
|
+
if (logger === noopLogger) console.error(message, error, event);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Invokes a single event listener in isolation, so that a faulty listener cannot
|
|
57
|
+
* abort the dispatch loop or the bookkeeping that follows it.
|
|
58
|
+
*/
|
|
59
|
+
export const invokeEventListener = <T>(
|
|
60
|
+
listener: (event: T) => unknown,
|
|
61
|
+
event: T,
|
|
62
|
+
logger: Logger,
|
|
63
|
+
) => {
|
|
64
|
+
try {
|
|
65
|
+
const result = listener(event);
|
|
66
|
+
if (result && typeof (result as PromiseLike<unknown>).then === 'function') {
|
|
67
|
+
Promise.resolve(result).catch((error) => logError(logger, error, event));
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
logError(logger, error, event);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
44
74
|
export const sleep = (m: number): Promise<void> => new Promise((r) => setTimeout(r, m));
|
|
45
75
|
|
|
46
76
|
export function isFunction(value: unknown): value is (...args: unknown[]) => unknown {
|
|
@@ -126,13 +156,6 @@ export const channelTracksReadLocally = (channel?: Channel) =>
|
|
|
126
156
|
!channelHasReadEvents(channel) &&
|
|
127
157
|
!!channel?.getClient().options.isLocalUnreadCountEnabled;
|
|
128
158
|
|
|
129
|
-
/**
|
|
130
|
-
* userHasReadReceipts - Whether the current user allows read receipts, per their privacy settings.
|
|
131
|
-
* Read receipts are treated as enabled unless the user has explicitly disabled them.
|
|
132
|
-
*/
|
|
133
|
-
export const userHasReadReceipts = (client: StreamChat) =>
|
|
134
|
-
client.user?.privacy_settings?.read_receipts?.enabled ?? true;
|
|
135
|
-
|
|
136
159
|
export function addFileToFormData(
|
|
137
160
|
uri: string | NodeJS.ReadableStream | Buffer | File,
|
|
138
161
|
name?: string,
|