stream-chat-react-native-core 5.7.1-beta.1 → 5.8.0-beta.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/lib/commonjs/components/Channel/Channel.js +35 -32
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/patchMessageTextCommand.js +26 -0
- package/lib/commonjs/utils/patchMessageTextCommand.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Channel/Channel.js +35 -32
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/patchMessageTextCommand.js +26 -0
- package/lib/module/utils/patchMessageTextCommand.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/utils/__tests__/patchMessageTextCommand.test.d.ts +1 -0
- package/lib/typescript/utils/patchMessageTextCommand.d.ts +9 -0
- package/package.json +1 -1
- package/src/components/Channel/Channel.tsx +5 -2
- package/src/index.ts +1 -0
- package/src/utils/__tests__/patchMessageTextCommand.test.ts +14 -0
- package/src/utils/patchMessageTextCommand.ts +35 -0
- package/src/version.json +1 -1
package/lib/module/index.js
CHANGED
|
@@ -180,6 +180,20 @@ Object.keys(_types).forEach(function (key) {
|
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
+
var _patchMessageTextCommand = require("./utils/patchMessageTextCommand");
|
|
184
|
+
|
|
185
|
+
Object.keys(_patchMessageTextCommand).forEach(function (key) {
|
|
186
|
+
if (key === "default" || key === "__esModule") return;
|
|
187
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
188
|
+
if (key in exports && exports[key] === _patchMessageTextCommand[key]) return;
|
|
189
|
+
Object.defineProperty(exports, key, {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
get: function get() {
|
|
192
|
+
return _patchMessageTextCommand[key];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
183
197
|
var _Streami18n = require("./utils/Streami18n");
|
|
184
198
|
|
|
185
199
|
Object.keys(_Streami18n).forEach(function (key) {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA","sourcesContent":["export * from './components';\nexport * from './hooks';\nexport { registerNativeHandlers, NetInfo } from './native';\nexport * from './contexts';\nexport * from './emoji-data/compiled';\n\nexport * from './icons';\n\nexport * from './types/types';\n\nexport * from './utils/Streami18n';\nexport * from './utils/utils';\n\nexport { default as enTranslations } from './i18n/en.json';\nexport { default as frTranslations } from './i18n/fr.json';\nexport { default as hiTranslations } from './i18n/hi.json';\nexport { default as itTranslations } from './i18n/it.json';\nexport { default as nlTranslations } from './i18n/nl.json';\nexport { default as ruTranslations } from './i18n/ru.json';\nexport { default as trTranslations } from './i18n/tr.json';\nexport { default as heTranslations } from './i18n/he.json';\n\nexport { QuickSqliteClient } from './store/QuickSqliteClient';\nexport { version } from './version.json';\n\nimport * as OfflineStoreApis from './store/apis';\nexport { OfflineStoreApis };\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA","sourcesContent":["export * from './components';\nexport * from './hooks';\nexport { registerNativeHandlers, NetInfo } from './native';\nexport * from './contexts';\nexport * from './emoji-data/compiled';\n\nexport * from './icons';\n\nexport * from './types/types';\n\nexport * from './utils/patchMessageTextCommand';\nexport * from './utils/Streami18n';\nexport * from './utils/utils';\n\nexport { default as enTranslations } from './i18n/en.json';\nexport { default as frTranslations } from './i18n/fr.json';\nexport { default as hiTranslations } from './i18n/hi.json';\nexport { default as itTranslations } from './i18n/it.json';\nexport { default as nlTranslations } from './i18n/nl.json';\nexport { default as ruTranslations } from './i18n/ru.json';\nexport { default as trTranslations } from './i18n/tr.json';\nexport { default as heTranslations } from './i18n/he.json';\n\nexport { QuickSqliteClient } from './store/QuickSqliteClient';\nexport { version } from './version.json';\n\nimport * as OfflineStoreApis from './store/apis';\nexport { OfflineStoreApis };\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.patchMessageTextCommand = patchMessageTextCommand;
|
|
5
|
+
|
|
6
|
+
function patchMessageTextCommand(messageText, mentionedUserIds) {
|
|
7
|
+
if (mentionedUserIds.length === 0) {
|
|
8
|
+
return messageText;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var trimmedMessageText = messageText.trim();
|
|
12
|
+
|
|
13
|
+
if (trimmedMessageText.startsWith('/mute ') || trimmedMessageText.startsWith('/unmute ') || trimmedMessageText.startsWith('/unban ')) {
|
|
14
|
+
return trimmedMessageText.replace(/@.+/, "@" + mentionedUserIds[0]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (trimmedMessageText.startsWith('/ban ')) {
|
|
18
|
+
var _trimmedMessageText$s;
|
|
19
|
+
|
|
20
|
+
var reasonText = (_trimmedMessageText$s = trimmedMessageText.split(' ').pop()) != null ? _trimmedMessageText$s : '';
|
|
21
|
+
return ("/ban @" + mentionedUserIds[0] + " " + reasonText).trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return messageText;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=patchMessageTextCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["patchMessageTextCommand.ts"],"names":["patchMessageTextCommand","messageText","mentionedUserIds","length","trimmedMessageText","trim","startsWith","replace","reasonText","split","pop"],"mappings":";;;;;AAQO,SAASA,uBAAT,CAAiCC,WAAjC,EAAsDC,gBAAtD,EAA0F;AAC/F,MAAIA,gBAAgB,CAACC,MAAjB,KAA4B,CAAhC,EAAmC;AACjC,WAAOF,WAAP;AACD;;AACD,MAAMG,kBAAkB,GAAGH,WAAW,CAACI,IAAZ,EAA3B;;AAKA,MACED,kBAAkB,CAACE,UAAnB,CAA8B,QAA9B,KACAF,kBAAkB,CAACE,UAAnB,CAA8B,UAA9B,CADA,IAEAF,kBAAkB,CAACE,UAAnB,CAA8B,SAA9B,CAHF,EAIE;AACA,WAAOF,kBAAkB,CAACG,OAAnB,CAA2B,KAA3B,QAAsCL,gBAAgB,CAAC,CAAD,CAAtD,CAAP;AACD;;AAKD,MAAIE,kBAAkB,CAACE,UAAnB,CAA8B,OAA9B,CAAJ,EAA4C;AAAA;;AAC1C,QAAME,UAAU,4BAAGJ,kBAAkB,CAACK,KAAnB,CAAyB,GAAzB,EAA8BC,GAA9B,EAAH,oCAA0C,EAA1D;AACA,WAAO,YAASR,gBAAgB,CAAC,CAAD,CAAzB,SAAgCM,UAAhC,EAA6CH,IAA7C,EAAP;AACD;;AAED,SAAOJ,WAAP;AACD","sourcesContent":["/**\n * Converts a message text command to proper format\n * Example: \"/mute @username\" to \"/mute @userId\"\n * Supports \"/ban\", \"/unban\", \"/mute\", \"/unmute\"\n * @param messageText\n * @param mentionedUsers\n * @returns\n */\nexport function patchMessageTextCommand(messageText: string, mentionedUserIds: string[]): string {\n if (mentionedUserIds.length === 0) {\n return messageText;\n }\n const trimmedMessageText = messageText.trim();\n\n /**\n * The required formats are \"/unban @userid\" or \"/mute @userid\" or \"/unmute @userid\"\n */\n if (\n trimmedMessageText.startsWith('/mute ') ||\n trimmedMessageText.startsWith('/unmute ') ||\n trimmedMessageText.startsWith('/unban ')\n ) {\n return trimmedMessageText.replace(/@.+/, `@${mentionedUserIds[0]}`);\n }\n\n /**\n * The required format is \"/ban @userid reason\"\n */\n if (trimmedMessageText.startsWith('/ban ')) {\n const reasonText = trimmedMessageText.split(' ').pop() ?? '';\n return `/ban @${mentionedUserIds[0]} ${reasonText}`.trim();\n }\n\n return messageText;\n}\n"]}
|
package/lib/module/version.json
CHANGED
|
@@ -5,6 +5,7 @@ export * from './contexts';
|
|
|
5
5
|
export * from './emoji-data/compiled';
|
|
6
6
|
export * from './icons';
|
|
7
7
|
export * from './types/types';
|
|
8
|
+
export * from './utils/patchMessageTextCommand';
|
|
8
9
|
export * from './utils/Streami18n';
|
|
9
10
|
export * from './utils/utils';
|
|
10
11
|
export { default as enTranslations } from './i18n/en.json';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a message text command to proper format
|
|
3
|
+
* Example: "/mute @username" to "/mute @userId"
|
|
4
|
+
* Supports "/ban", "/unban", "/mute", "/unmute"
|
|
5
|
+
* @param messageText
|
|
6
|
+
* @param mentionedUsers
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function patchMessageTextCommand(messageText: string, mentionedUserIds: string[]): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.8.0-beta.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -79,6 +79,7 @@ import * as dbApi from '../../store/apis';
|
|
|
79
79
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
80
80
|
import { addReactionToLocalState } from '../../utils/addReactionToLocalState';
|
|
81
81
|
import { DBSyncManager } from '../../utils/DBSyncManager';
|
|
82
|
+
import { patchMessageTextCommand } from '../../utils/patchMessageTextCommand';
|
|
82
83
|
import { removeReactionFromLocalState } from '../../utils/removeReactionFromLocalState';
|
|
83
84
|
import { generateRandomId, isLocalUrl, MessageStatusTypes, ReactionData } from '../../utils/utils';
|
|
84
85
|
import { Attachment as AttachmentDefault } from '../Attachment/Attachment';
|
|
@@ -1332,12 +1333,14 @@ const ChannelWithContext = <
|
|
|
1332
1333
|
} = updatedMessage;
|
|
1333
1334
|
if (!channel.id) return;
|
|
1334
1335
|
|
|
1336
|
+
const mentionedUserIds = mentioned_users?.map((user) => user.id) || [];
|
|
1337
|
+
|
|
1335
1338
|
const messageData = {
|
|
1336
1339
|
attachments,
|
|
1337
1340
|
id,
|
|
1338
|
-
mentioned_users:
|
|
1341
|
+
mentioned_users: mentionedUserIds,
|
|
1339
1342
|
parent_id,
|
|
1340
|
-
text,
|
|
1343
|
+
text: patchMessageTextCommand(text ?? '', mentionedUserIds),
|
|
1341
1344
|
...extraFields,
|
|
1342
1345
|
} as StreamMessage<StreamChatGenerics>;
|
|
1343
1346
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { patchMessageTextCommand } from '../patchMessageTextCommand';
|
|
2
|
+
|
|
3
|
+
describe('patchMessageTextCommand', () => {
|
|
4
|
+
test.each<[string, string, string[]]>([
|
|
5
|
+
['/ban @santhosh vaiyapuri reason', '/ban @santhosh reason', ['santhosh']],
|
|
6
|
+
['/ban @santhosh vaiyapuri', '/ban @santhosh vaiyapuri', ['santhosh']],
|
|
7
|
+
['/ban @santhosh', '/ban @santhosh @santhosh', ['santhosh']],
|
|
8
|
+
['/ban @santhosh vaiyapuri @khushal reason', '/ban @santhosh reason', ['santhosh', 'khushal']],
|
|
9
|
+
['/mute @santhosh vaiyapuri', '/mute @santhosh', ['santhosh']],
|
|
10
|
+
['/mute @santhosh vaiyapuri @khushal reason', '/mute @santhosh', ['santhosh', 'khushal']],
|
|
11
|
+
])('Patch message with text:"%s" to "%s")', (input, expectedOutput, mentionedUserIds) => {
|
|
12
|
+
expect(patchMessageTextCommand(input, mentionedUserIds)).toBe(expectedOutput);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a message text command to proper format
|
|
3
|
+
* Example: "/mute @username" to "/mute @userId"
|
|
4
|
+
* Supports "/ban", "/unban", "/mute", "/unmute"
|
|
5
|
+
* @param messageText
|
|
6
|
+
* @param mentionedUsers
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export function patchMessageTextCommand(messageText: string, mentionedUserIds: string[]): string {
|
|
10
|
+
if (mentionedUserIds.length === 0) {
|
|
11
|
+
return messageText;
|
|
12
|
+
}
|
|
13
|
+
const trimmedMessageText = messageText.trim();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The required formats are "/unban @userid" or "/mute @userid" or "/unmute @userid"
|
|
17
|
+
*/
|
|
18
|
+
if (
|
|
19
|
+
trimmedMessageText.startsWith('/mute ') ||
|
|
20
|
+
trimmedMessageText.startsWith('/unmute ') ||
|
|
21
|
+
trimmedMessageText.startsWith('/unban ')
|
|
22
|
+
) {
|
|
23
|
+
return trimmedMessageText.replace(/@.+/, `@${mentionedUserIds[0]}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The required format is "/ban @userid reason"
|
|
28
|
+
*/
|
|
29
|
+
if (trimmedMessageText.startsWith('/ban ')) {
|
|
30
|
+
const reasonText = trimmedMessageText.split(' ').pop() ?? '';
|
|
31
|
+
return `/ban @${mentionedUserIds[0]} ${reasonText}`.trim();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return messageText;
|
|
35
|
+
}
|
package/src/version.json
CHANGED