protected override async Task OnInitializedAsync() { Snackbar.Clear(); if (!string.IsNullOrWhiteSpace(this.SnippetId)) { try { this.CodeFiles = (await this.SnippetsService.GetSnippetContentAsync(this.SnippetId)).ToDictionary(f => f.Path, f => f); if (!this.CodeFiles.Any()) { this.errorMessage = "No files in snippet."; } else { this.activeCodeFile = this.CodeFiles.First().Value; } } catch (ArgumentException) { this.errorMessage = "Invalid Snippet ID."; } catch (Exception) { this.errorMessage = "Unable to get snippet content. Please try again later."; } } if (!this.CodeFiles.Any()) { this.activeCodeFile = new CodeFile { Path = CoreConstants.MainComponentFilePath, Content = CoreConstants.MainComponentDefaultFileContent, }; this.CodeFiles.Add(CoreConstants.MainComponentFilePath, this.activeCodeFile); } this.CodeFileNames = this.CodeFiles.Keys.ToList(); await base.OnInitializedAsync(); }