Skip to content

Commit

Permalink
Fixes export dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Apr 2, 2024
1 parent 04318d6 commit 98face0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
12 changes: 2 additions & 10 deletions AudioCuesheetEditor/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,9 @@ along with Foobar. If not, see
_logger.LogInformation("SelectedExportProfileChanged with {0}", newValue);
selectedExportProfileId = newValue;
modalExportdialogExportprofile?.Validations?.ValidateAll().GetAwaiter().GetResult();
if ((modalExportdialogExportprofile != null) && (modalExportdialogExportprofile.ExportfileGenerator != null))
if (modalExportdialogExportprofile != null)
{
modalExportdialogExportprofile.ExportfileGenerator.Exportprofile = SelectedExportProfile;
modalExportdialogExportprofile.SelectedExportProfile = SelectedExportProfile;
modalExportdialogExportprofile.Reset();
}
StateHasChanged();
Expand Down Expand Up @@ -797,19 +797,11 @@ along with Foobar. If not, see
void ModalExportdialogExportprofile_GenerateExportfilesClicked(object? sender, EventArgs args)
{
Task.Run(SaveExportProfiles);
if ((modalExportdialogExportprofile != null) && (modalExportdialogExportprofile.ExportfileGenerator != null))
{
modalExportdialogExportprofile.ExportfileGenerator.Exportprofile = SelectedExportProfile;
}
}

void ModalExportdialogCuesheet_GenerateExportfilesClicked(object? sender, EventArgs args)
{
Task.Run(SaveApplicationOptions);
if ((modalExportdialogCuesheet != null) && (modalExportdialogCuesheet.ExportfileGenerator != null))
{
modalExportdialogCuesheet.ExportfileGenerator.ApplicationOptions = applicationOptions;
}
}

Task OnApplicationOptionsCuesheetFilenameChanged(string value)
Expand Down
30 changes: 17 additions & 13 deletions AudioCuesheetEditor/Shared/ModalExportdialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ along with Foobar. If not, see
</Modal>

@code {
//TODO: Export of cuesheet doesn't work (ApplicationOptions missing in ExportfileGenerator)
public event EventHandler? GenerateExportfilesClicked;

[Parameter]
Expand All @@ -125,9 +124,10 @@ along with Foobar. If not, see
[EditorRequired]
public ExportType ExportType { get; set; }

public Exportprofile? SelectedExportProfile{ get; set; }

public Boolean IsVisible { get; private set; }
public Validations? Validations { get; private set; }
public ExportfileGenerator? ExportfileGenerator { get; private set; }
public Boolean LockUserInputs { get => exportProgress != null; }

Modal? modalExportdialog;
Expand All @@ -136,6 +136,7 @@ along with Foobar. If not, see
Boolean prepareExportCompleted = false;
HotKeysContext? hotKeysContext;
int? exportProgress;
ApplicationOptions? applicationOptions;

Boolean StepNavigationAllowed
{
Expand All @@ -162,7 +163,8 @@ along with Foobar. If not, see
{
get
{
var validationResult = ExportfileGenerator?.Validate();
var generator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet, SelectedExportProfile, applicationOptions);
var validationResult = generator.Validate();
if (validationResult?.Status == Model.Entity.ValidationStatus.Error)
{
string? detailText = null;
Expand Down Expand Up @@ -197,14 +199,16 @@ along with Foobar. If not, see
hotKeysContext = _hotKeys.CreateContext()
.Add(Key.Enter, OnEnterKeyDown);

ExportfileGenerator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet);
applicationOptions = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
_localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionSaved;

await base.OnInitializedAsync();
}

public void Dispose()
{
hotKeysContext?.Dispose();
_localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionSaved;
}

public async Task Show()
Expand Down Expand Up @@ -240,12 +244,10 @@ along with Foobar. If not, see
{
GenerateExportfilesClicked?.Invoke(this, EventArgs.Empty);
exportProgress = 0;
if (ExportfileGenerator != null)
{
exportfiles = ExportfileGenerator.GenerateExportfiles();
selectedStep = "displayExportResult";
prepareExportCompleted = true;
}
var generator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet, SelectedExportProfile, applicationOptions);
exportfiles = generator.GenerateExportfiles();
selectedStep = "displayExportResult";
prepareExportCompleted = true;
exportProgress = null;
}
return Task.CompletedTask;
Expand Down Expand Up @@ -281,9 +283,11 @@ along with Foobar. If not, see
}
}

void IAudioConverterService_ProgressChanged(object? sender, int progress)
void LocalStorageOptionsProvider_OptionSaved(object? sender, IOptions options)
{
exportProgress = progress;
InvokeAsync(StateHasChanged);
if (options is ApplicationOptions)
{
applicationOptions = (ApplicationOptions)options;
}
}
}

0 comments on commit 98face0

Please sign in to comment.