protected override async Task OnInitializedAsync() { loadFileModel = new LoadFileModel(); loadFileModel.AllowedExtension = GetAllowedExtension(); loadFileModel.ContentLoaded += FileLoaded; savesAsFileModel = new SaveAsFileModel(); savesAsFileModel.SaveFileAs += SaveAsAsyncCallBack; SelectedCodeSample = 0; abiCodeGenerateModel = new AbiCodeGenerateModel(); abiCodeGenerateModel.CodeGenerate += AbiCodeGenerateCallBack; Task.Run(() => ProjectEditorInitialiser.InitialiseProject(GetEditorLanguage())); }
/// <summary> /// Super workaround: /// Storage is not available until we have rendered, /// We can then load User code samples stored in storage /// But if we call StateHasChanged then the Editor is duplicated /// So to avoid this a timer is set to run only one which will call StateHasChanged after /// 1 second /// </summary> /// <returns></returns> protected override async Task OnAfterRenderAsync() { ProjectEditorInitialiser.InitialiseProject(GetEditorLanguage()); if (!CodeSampleRepository.LoadedUserSamples) { await LoadSavedAsync(); //waiting a second to do a state has changed to display the items // and avoid confusion with the editor. _timer = new Timer(new TimerCallback(_ => { StateHasChanged(); _timer.Dispose(); }), null, 1000, 1000); } }