stream-chat 9.46.0 → 9.47.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 +15 -14
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +11 -13
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +15 -14
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +1 -1
- package/package.json +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +14 -13
|
@@ -11,7 +11,6 @@ export declare const accentsMap: {
|
|
|
11
11
|
export declare const removeDiacritics: (text?: string) => string;
|
|
12
12
|
export declare const calculateLevenshtein: (query: string, name: string) => number;
|
|
13
13
|
export type MentionsSearchSourceOptions = SearchSourceOptions & {
|
|
14
|
-
allowedMentionTypes?: Partial<Record<MentionType, boolean>>;
|
|
15
14
|
mentionAllAppUsers?: boolean;
|
|
16
15
|
suggestionFactoryMappers?: MentionSuggestionFactoryMapperOverrides;
|
|
17
16
|
textComposerText?: string;
|
|
@@ -41,6 +40,7 @@ export type MentionSuggestionFactoryMapper<TMentionType extends MentionType = Me
|
|
|
41
40
|
export type MentionSuggestionFactoryMapperOverrides = {
|
|
42
41
|
[TMentionType in MentionType]?: MentionSuggestionFactoryMapper<TMentionType>;
|
|
43
42
|
};
|
|
43
|
+
export declare const getAllowedMentionTypesFromCapabilities: (ownCapabilities?: string[]) => Record<MentionType, boolean>;
|
|
44
44
|
type UserPaginationState = {
|
|
45
45
|
itemCount: number;
|
|
46
46
|
nextOffset?: number;
|
package/package.json
CHANGED
|
@@ -92,7 +92,6 @@ export const calculateLevenshtein = (query: string, name: string) => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
export type MentionsSearchSourceOptions = SearchSourceOptions & {
|
|
95
|
-
allowedMentionTypes?: Partial<Record<MentionType, boolean>>;
|
|
96
95
|
mentionAllAppUsers?: boolean;
|
|
97
96
|
suggestionFactoryMappers?: MentionSuggestionFactoryMapperOverrides;
|
|
98
97
|
textComposerText?: string;
|
|
@@ -134,13 +133,18 @@ export type MentionSuggestionFactoryMapperOverrides = {
|
|
|
134
133
|
[TMentionType in MentionType]?: MentionSuggestionFactoryMapper<TMentionType>;
|
|
135
134
|
};
|
|
136
135
|
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
const hasOwnCapability = (ownCapabilities: string[] | undefined, capability: string) =>
|
|
137
|
+
ownCapabilities?.includes(capability) ?? false;
|
|
138
|
+
|
|
139
|
+
export const getAllowedMentionTypesFromCapabilities = (
|
|
140
|
+
ownCapabilities?: string[],
|
|
141
|
+
): Record<MentionType, boolean> => ({
|
|
142
|
+
channel: hasOwnCapability(ownCapabilities, 'notify-channel'),
|
|
143
|
+
here: hasOwnCapability(ownCapabilities, 'notify-here'),
|
|
144
|
+
role: hasOwnCapability(ownCapabilities, 'notify-role'),
|
|
141
145
|
user: true,
|
|
142
|
-
user_group:
|
|
143
|
-
};
|
|
146
|
+
user_group: hasOwnCapability(ownCapabilities, 'notify-group'),
|
|
147
|
+
});
|
|
144
148
|
|
|
145
149
|
type UserGroupSearchCursor = Pick<SearchUserGroupsOptions, 'id_gt' | 'name_gt'>;
|
|
146
150
|
type UserPaginationState = {
|
|
@@ -299,7 +303,6 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
|
|
|
299
303
|
|
|
300
304
|
constructor(channel: Channel, options?: MentionsSearchSourceOptions) {
|
|
301
305
|
const {
|
|
302
|
-
allowedMentionTypes,
|
|
303
306
|
mentionAllAppUsers,
|
|
304
307
|
suggestionFactoryMappers,
|
|
305
308
|
textComposerText,
|
|
@@ -311,10 +314,6 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
|
|
|
311
314
|
this.client = channel.getClient();
|
|
312
315
|
this.channel = channel;
|
|
313
316
|
this.config = {
|
|
314
|
-
allowedMentionTypes: {
|
|
315
|
-
...DEFAULT_ALLOWED_MENTION_TYPES,
|
|
316
|
-
...allowedMentionTypes,
|
|
317
|
-
},
|
|
318
317
|
mentionAllAppUsers,
|
|
319
318
|
suggestionFactoryMappers,
|
|
320
319
|
textComposerText,
|
|
@@ -371,7 +370,9 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
|
|
|
371
370
|
};
|
|
372
371
|
|
|
373
372
|
isMentionTypeAllowed = (mentionType: MentionType) =>
|
|
374
|
-
this.
|
|
373
|
+
getAllowedMentionTypesFromCapabilities(this.channel.data?.own_capabilities)[
|
|
374
|
+
mentionType
|
|
375
|
+
];
|
|
375
376
|
|
|
376
377
|
protected mapMentionSuggestion = <TMentionType extends MentionType>(
|
|
377
378
|
mentionType: TMentionType,
|