Skip to content

Commit

Permalink
#2257 - Add types or comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleicul committed Apr 20, 2023
1 parent 03bdfaf commit c6c40a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/ketcher-core/src/application/editor/actions/bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function fromBondAddition(
action.addOp(new FragmentAdd().perform(reStruct)) as FragmentAdd
).frid

const newBeginAtomId = (
const newBeginAtomId: number = (
action.addOp(
new AtomAdd(
{ ...beginAtomAttr, fragment: newFragmentId },
Expand All @@ -76,7 +76,7 @@ export function fromBondAddition(
) as AtomAdd
).data.aid

const newEndAtomId = (
const newEndAtomId: number = (
action.addOp(
new AtomAdd(
{ ...endAtomAttr, fragment: newFragmentId },
Expand All @@ -94,7 +94,7 @@ export function fromBondAddition(
) => {
const fragmentId = atomGetAttr(reStruct, endAtomId, 'fragment')

const newBeginAtomId = (
const newBeginAtomId: number = (
action.addOp(
new AtomAdd(
{ ...beginAtomAttr, fragment: fragmentId },
Expand Down Expand Up @@ -122,7 +122,7 @@ export function fromBondAddition(
) => {
const fragmentId = atomGetAttr(reStruct, beginAtomId, 'fragment')

const newEndAtomId = (
const newEndAtomId: number = (
action.addOp(
new AtomAdd(
{
Expand Down
3 changes: 3 additions & 0 deletions packages/ketcher-core/src/domain/entities/sgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ export class SGroup {
return !expanded && isSGroup
}

/**
* @returns `undefined`: if it's salt or solvent
*/
static getAttachmentAtomIdBySGroupId(sGroupId: number, struct: Struct) {
const functionalGroup = struct.functionalGroups.get(sGroupId)
if (!SGroup.isSaltOrSolvent(functionalGroup?.name || '')) {
Expand Down
8 changes: 4 additions & 4 deletions packages/ketcher-react/src/script/editor/tool/bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ class BondTool {
) {
const closestAttachmentAtomId =
SGroup.getAttachmentAtomIdBySGroupId(closestSGroup.id, molecule)
if (
closestAttachmentAtomId &&
closestAttachmentAtomId !== beginAtom
) {
const isSaltOrSolvent = closestAttachmentAtomId === undefined
const isBeginFunctionalGroupItself =
closestAttachmentAtomId === beginAtom
if (!isSaltOrSolvent && !isBeginFunctionalGroupItself) {
endAtom = {
id: closestAttachmentAtomId,
map: 'atoms'
Expand Down

0 comments on commit c6c40a9

Please sign in to comment.