diff --git a/AudioCuesheetEditor/Pages/ViewModeImport.razor b/AudioCuesheetEditor/Pages/ViewModeImport.razor index 0eea12e9..49325a57 100644 --- a/AudioCuesheetEditor/Pages/ViewModeImport.razor +++ b/AudioCuesheetEditor/Pages/ViewModeImport.razor @@ -133,7 +133,7 @@ along with Foobar. If not, see - + @_localizer["Reset import options"] @@ -446,4 +446,12 @@ along with Foobar. If not, see validations.ValidateAll().GetAwaiter().GetResult(); } } + + async Task EditImportOptions_OptionsChanged(ImportOptions importOptions) + { + if (_sessionStateContainer.TextImportFile?.FileContent != null) + { + await _importManager.ImportTextAsync(_sessionStateContainer.TextImportFile.FileContent); + } + } } diff --git a/AudioCuesheetEditor/Services/IO/ImportManager.cs b/AudioCuesheetEditor/Services/IO/ImportManager.cs index 41181104..28d4f07c 100644 --- a/AudioCuesheetEditor/Services/IO/ImportManager.cs +++ b/AudioCuesheetEditor/Services/IO/ImportManager.cs @@ -68,8 +68,6 @@ public async Task> ImportFilesAsync(IEnum if (IOUtility.CheckFileMimeType(file, TextImportfile.MimeType, TextImportfile.FileExtension)) { var fileContent = await ReadFileContentAsync(file); - var options = await _localStorageOptionsProvider.GetOptions(); - var applicationOptions = await _localStorageOptionsProvider.GetOptions(); fileContent.Position = 0; using var reader = new StreamReader(fileContent); List lines = []; @@ -77,13 +75,7 @@ public async Task> ImportFilesAsync(IEnum { lines.Add(reader.ReadLine()); } - _sessionStateContainer.TextImportFile = _textImportService.Analyse(options, lines); - if (_textImportService.AnalysedCuesheet != null) - { - var importCuesheet = new Cuesheet(); - importCuesheet.Import(_textImportService.AnalysedCuesheet, applicationOptions); - _sessionStateContainer.ImportCuesheet = importCuesheet; - } + await ImportTextAsync([.. lines]); importFileTypes.Add(file, ImportFileType.Textfile); } if (IOUtility.CheckFileMimeTypeForAudioCodec(file)) @@ -98,6 +90,20 @@ public async Task> ImportFilesAsync(IEnum } return importFileTypes; } + + public async Task ImportTextAsync(IEnumerable fileContent) + { + var options = await _localStorageOptionsProvider.GetOptions(); + _sessionStateContainer.TextImportFile = _textImportService.Analyse(options, fileContent); + if (_textImportService.AnalysedCuesheet != null) + { + var applicationOptions = await _localStorageOptionsProvider.GetOptions(); + var importCuesheet = new Cuesheet(); + importCuesheet.Import(_textImportService.AnalysedCuesheet, applicationOptions); + _sessionStateContainer.ImportCuesheet = importCuesheet; + } + } + private static async Task ReadFileContentAsync(IFileEntry file) { var fileContent = new MemoryStream(); diff --git a/AudioCuesheetEditor/Shared/EditImportOptions.razor b/AudioCuesheetEditor/Shared/EditImportOptions.razor index 8b92868b..38cb98ee 100644 --- a/AudioCuesheetEditor/Shared/EditImportOptions.razor +++ b/AudioCuesheetEditor/Shared/EditImportOptions.razor @@ -126,7 +126,9 @@ along with Foobar. If not, see @code{ - //TODO: Changes to ImportOptions need to do a reanalysis + [Parameter] + public EventCallback OptionsChanged { get; set; } + public ImportOptions? ImportOptions { get; private set; } public void Dispose() @@ -172,5 +174,6 @@ along with Foobar. If not, see } setter(ImportOptions, text); await _localStorageOptionsProvider.SaveOptions(ImportOptions); + await OptionsChanged.InvokeAsync(ImportOptions); } } \ No newline at end of file