2021-04-28 23:11:20 +02:00
|
|
|
import { isEmpty } from 'lodash-es';
|
2021-08-02 15:39:40 +02:00
|
|
|
import { toSortedArray } from '../../../../../utils/sort-files';
|
2020-08-12 13:11:17 +03:00
|
|
|
|
|
|
|
export function getTargetEditor(challengeFiles) {
|
|
|
|
if (isEmpty(challengeFiles)) return null;
|
|
|
|
else {
|
2021-08-12 19:48:28 +01:00
|
|
|
let targetEditor = challengeFiles.find(
|
2020-08-12 13:11:17 +03:00
|
|
|
({ editableRegionBoundaries }) => !isEmpty(editableRegionBoundaries)
|
2021-08-12 19:48:28 +01:00
|
|
|
)?.fileKey;
|
2020-08-12 13:11:17 +03:00
|
|
|
|
|
|
|
// fallback for when there is no editable region.
|
2021-08-12 19:48:28 +01:00
|
|
|
return targetEditor || toSortedArray(challengeFiles)[0].fileKey;
|
2020-08-12 13:11:17 +03:00
|
|
|
}
|
|
|
|
}
|