Skip to content

Commit

Permalink
reduced complexity of importmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Aug 28, 2024
1 parent e77f89e commit 38db9d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 13 additions & 0 deletions AudioCuesheetEditor/Pages/ViewModeImport.razor
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,19 @@ along with Foobar. If not, see
{
_sessionStateContainer.ResetImport();
var importedFiles = await _importManager.ImportFilesAsync(files);
// Audio file is handled seperatly
foreach (var file in files)
{
if (IOUtility.CheckFileMimeTypeForAudioCodec(file))
{
var audioFileObjectURL = await _jsRuntime.InvokeAsync<String>("getObjectURL", "dropFileInput");
var codec = IOUtility.GetAudioCodec(file);
var audiofile = new Audiofile(file.Name, audioFileObjectURL, codec, _httpClient);
_ = audiofile.LoadContentStream();
_sessionStateContainer.ImportAudiofile = audiofile;
importedFiles.Add(file, ImportFileType.Audiofile);
}
}
displaySplitPoints = importedFiles.ContainsValue(ImportFileType.ProjectFile);
await OnSelectedStepChanged("validateData");
StateHasChanged();
Expand Down
13 changes: 1 addition & 12 deletions AudioCuesheetEditor/Services/IO/ImportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ public enum ImportFileType
Textfile,
Audiofile
}
public class ImportManager(SessionStateContainer sessionStateContainer, LocalStorageOptionsProvider localStorageOptionsProvider, IJSRuntime jsRuntime, HttpClient httpClient, TextImportService textImportService, CuesheetImportService cuesheetImportService)
public class ImportManager(SessionStateContainer sessionStateContainer, LocalStorageOptionsProvider localStorageOptionsProvider, TextImportService textImportService, CuesheetImportService cuesheetImportService)
{
private readonly SessionStateContainer _sessionStateContainer = sessionStateContainer;
private readonly LocalStorageOptionsProvider _localStorageOptionsProvider = localStorageOptionsProvider;
private readonly IJSRuntime _jsRuntime = jsRuntime;
private readonly HttpClient _httpClient = httpClient;
private readonly TextImportService _textImportService = textImportService;
private readonly CuesheetImportService _cuesheetImportService = cuesheetImportService;

Expand Down Expand Up @@ -84,15 +82,6 @@ public async Task<Dictionary<IFileEntry, ImportFileType>> ImportFilesAsync(IEnum
await ImportTextAsync([.. lines]);
importFileTypes.Add(file, ImportFileType.Textfile);
}
if (IOUtility.CheckFileMimeTypeForAudioCodec(file))
{
var audioFileObjectURL = await _jsRuntime.InvokeAsync<String>("getObjectURL", "dropFileInput");
var codec = IOUtility.GetAudioCodec(file);
var audiofile = new Audiofile(file.Name, audioFileObjectURL, codec, _httpClient);
_ = audiofile.LoadContentStream();
_sessionStateContainer.ImportAudiofile = audiofile;
importFileTypes.Add(file, ImportFileType.Audiofile);
}
}
return importFileTypes;
}
Expand Down

0 comments on commit 38db9d1

Please sign in to comment.