diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index a69729dd23..e9d3eb1a52 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -2200,32 +2200,35 @@ const recreateConversationEpic: AppEpic = (action$) => action$.pipe( filter(ConversationsActions.recreateConversation.match), mergeMap(({ payload }) => { - return zip( - ConversationService.createConversation(payload.new), - ConversationService.deleteConversation( - getConversationInfoFromId(payload.old.id), - ), - ).pipe( - switchMap(() => EMPTY), - catchError((err) => { - console.error(err); - return concat( - of( - ConversationsActions.recreateConversationFail({ - newId: payload.new.id, - oldConversation: payload.old, - }), + return ConversationService.createConversation(payload.new) + .pipe( + switchMap(() => + ConversationService.deleteConversation( + getConversationInfoFromId(payload.old.id), ), - of( - UIActions.showErrorToast( - translate( - 'An error occurred while saving the conversation. Please refresh the page.', + ), + ) + .pipe( + switchMap(() => EMPTY), + catchError((err) => { + console.error(err); + return concat( + of( + ConversationsActions.recreateConversationFail({ + newId: payload.new.id, + oldConversation: payload.old, + }), + ), + of( + UIActions.showErrorToast( + translate( + 'An error occurred while saving the conversation. Please refresh the page.', + ), ), ), - ), - ); - }), - ); + ); + }), + ); }), ); diff --git a/apps/chat/src/utils/app/common.ts b/apps/chat/src/utils/app/common.ts index 2cbb5c4547..c30986289e 100644 --- a/apps/chat/src/utils/app/common.ts +++ b/apps/chat/src/utils/app/common.ts @@ -8,6 +8,7 @@ import { MAX_ENTITY_LENGTH } from '@/src/constants/default-ui-settings'; import trimEnd from 'lodash-es/trimEnd'; import uniq from 'lodash-es/uniq'; +import { substring } from 'stringz'; /** * Combine entities. If there are the same ids then will be used entity from entities1 i.e. first in array @@ -99,7 +100,7 @@ export const prepareEntityName = (name: string, forRenaming = false) => { .filter(Boolean)[0] ?? ''; if (clearName.length > MAX_ENTITY_LENGTH) { - return trimEndDots(clearName.substring(0, MAX_ENTITY_LENGTH)); + return trimEndDots(substring(clearName, 0, MAX_ENTITY_LENGTH)); } return trimEndDots(clearName); diff --git a/package-lock.json b/package-lock.json index ce4025dfce..c23a6a15a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,7 @@ "rehype-sanitize": "^5.0.1", "remark-gfm": "^3.0.1", "rxjs": "^7.8.1", + "stringz": "^2.1.0", "svgo": "^3.0.2", "tslib": "^2.6.0" }, @@ -8960,7 +8961,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", - "dev": true, "engines": { "node": ">=10" } @@ -19516,6 +19516,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/stringz": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/stringz/-/stringz-2.1.0.tgz", + "integrity": "sha512-KlywLT+MZ+v0IRepfMxRtnSvDCMc3nR1qqCs3m/qIbSOWkNZYT8XHQA31rS3TnKp0c5xjZu3M4GY/2aRKSi/6A==", + "dependencies": { + "char-regex": "^1.0.2" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", diff --git a/package.json b/package.json index 32fff3f639..b4ce8c11f0 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "rehype-sanitize": "^5.0.1", "remark-gfm": "^3.0.1", "rxjs": "^7.8.1", + "stringz": "^2.1.0", "svgo": "^3.0.2", "tslib": "^2.6.0" },