From 45c8899f06932692c09766451facdc9dc11c8e69 Mon Sep 17 00:00:00 2001 From: Neil Brommer Date: Wed, 20 Apr 2022 16:48:59 -0700 Subject: [PATCH] Create a default container if none exist --- .../ContainersList/ContainerListEffects.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Start/Client/Store/Features/ContainersList/ContainerListEffects.cs b/Start/Client/Store/Features/ContainersList/ContainerListEffects.cs index a5712d0..b534a3e 100644 --- a/Start/Client/Store/Features/ContainersList/ContainerListEffects.cs +++ b/Start/Client/Store/Features/ContainersList/ContainerListEffects.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Fluxor; using Microsoft.AspNetCore.Components.WebAssembly.Authentication; using Refit; +using Start.Client.Store.Features.CreateContainer; using Start.Shared; using Start.Shared.Api; @@ -33,8 +34,23 @@ namespace Start.Client.Store.Features.ContainersList { return; } - if (!bookmarkContainers.Any()) - throw new NotImplementedException("Create bookmark effect has not been created"); + if (!bookmarkContainers.Any()) { + dispatch.Dispatch(new SubmitCreateContainerAction( + new BookmarkContainerDto("Default", 0))); + + // And load again + response = await this + .BookmarkContainersApi + .GetAllBookmarkContainers(); + + bookmarkContainers = response.Content?.ToList(); + + if (bookmarkContainers == null) { + dispatch.Dispatch(new ErrorFetchingContainerListAction( + "Failed to fetch containers list")); + return; + } + } dispatch.Dispatch(new RecievedContainerListAction(bookmarkContainers)); }