Skip to content

Commit

Permalink
Fixed editor in Script block not updating correctly
Browse files Browse the repository at this point in the history
Closes #116
  • Loading branch information
openbullet committed Mar 16, 2021
1 parent 18fa8dd commit 835a24b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions OpenBullet2/Pages/Stacker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using OpenBullet2.Shared;
using RuriLib.Helpers.Blocks;
using RuriLib.Models.Blocks;
using RuriLib.Models.Blocks.Custom;
using RuriLib.Models.Configs;
using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -47,10 +48,10 @@ protected override async Task OnInitializedAsync()

private async Task SelectedBlock(BlockInstance block)
{
// If we're switching between 2 lolicode blocks, do this to force a refresh
// If we're switching between 2 blocks that have a Monaco Editor, do this to force a refresh
// of the component, otherwise the text in the editor does not update
if (selectedBlock != null && selectedBlock is LoliCodeBlockInstance &&
block != null && block is LoliCodeBlockInstance)
if (selectedBlock != null && HasMonacoEditor(selectedBlock) &&
block != null && HasMonacoEditor(block))
{
selectedBlock = null;
StateHasChanged();
Expand All @@ -62,5 +63,8 @@ private async Task SelectedBlock(BlockInstance block)
selectedBlock = block;
}
}

private bool HasMonacoEditor(BlockInstance block)
=> block is LoliCodeBlockInstance or ScriptBlockInstance;
}
}

0 comments on commit 835a24b

Please sign in to comment.