Skip to content

Commit

Permalink
Rename addedFile #3899
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMehl committed Jan 31, 2025
1 parent 77ce739 commit fb16860
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions visualization/app/codeCharta/services/loadFile/fileParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function enrichFileStatesAndRecentFilesWithValidationResults(
currentFilesAreSampleFilesCallback: () => boolean,
setCurrentFilesAreNotSampleFilesCallback: () => void
): boolean {
let newFilesWereAdded = false
let hasAddedAtLeastOneFile = false
for (const nameDataPair of nameDataPairs) {
const fileValidationResult: FileValidationResult = {
fileName: nameDataPair?.fileName,
Expand All @@ -60,23 +60,23 @@ export function enrichFileStatesAndRecentFilesWithValidationResults(

if (fileValidationResult.errors.length === 0) {
fileValidationResult.warnings.push(...checkWarnings(nameDataPair?.content))
const addedFile = addFile(
const hasAddedFile = addFile(
fileStates,
recentFiles,
nameDataPair,
currentFilesAreSampleFilesCallback,
setCurrentFilesAreNotSampleFilesCallback
)
if (addedFile) {
newFilesWereAdded = true
if (hasAddedFile) {
hasAddedAtLeastOneFile = true
}
}

if (fileValidationResult.errors.length > 0 || fileValidationResult.warnings.length > 0) {
fileValidationResults.push(fileValidationResult)
}
}
return newFilesWereAdded
return hasAddedAtLeastOneFile
}

function addFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class LoadFileService implements OnDestroy {
const recentFiles: string[] = []
const fileValidationResults: CCFileValidationResult[] = []

const newFilesWereAdded = enrichFileStatesAndRecentFilesWithValidationResults(
const hasAddedAtLeastOneFile = enrichFileStatesAndRecentFilesWithValidationResults(
fileStates,
recentFiles,
nameDataPairs,
Expand All @@ -73,7 +73,7 @@ export class LoadFileService implements OnDestroy {
this.store.dispatch(setStandardByNames({ fileNames: recentFiles }))
fileRoot.updateRoot(rootName)

if (!newFilesWereAdded) {
if (!hasAddedAtLeastOneFile) {
throw new Error(FILES_ALREADY_LOADED_ERROR_MESSAGE)
}
}
Expand Down

0 comments on commit fb16860

Please sign in to comment.