Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/epam/ai-dial-chat in…
Browse files Browse the repository at this point in the history
…to 128-need-to-make-side-panels-resizable
  • Loading branch information
denys-kolomiitsev committed Dec 11, 2023
2 parents ab286b9 + b2d6a48 commit 141ce96
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/utils/app/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ export const getNextDefaultName = (
return `${prefix}${1 + index}`;
}

const numeredEntities = entities
.filter((entity) => entity.name.match(regex))
.map((entity) => entity.name.replace(prefix, '').trim())
.sort()
.reverse(); // max number

return `${prefix}${
(numeredEntities.length ? parseInt(numeredEntities[0]) + 1 : 1) + index
}`;
const maxNumber = Math.max(
...entities
.filter((entity) => entity.name.match(regex))
.map((entity) => parseInt(entity.name.replace(prefix, ''), 10)),
0,
); // max number

return `${prefix}${maxNumber + 1 + index}`;
};

0 comments on commit 141ce96

Please sign in to comment.