avoid the infinite loop issue of calling AddModuleMessage method.
This commit is contained in:
		| @ -10,19 +10,13 @@ | ||||
|         { | ||||
|             @if (ModuleType != null) | ||||
|             { | ||||
|                 @if (!string.IsNullOrEmpty(_messageContent) && _messagePosition == "top") | ||||
|                 { | ||||
|                     <ModuleMessage Message="@_messageContent" Type="@_messageType" /> | ||||
|                 } | ||||
|                 <ModuleMessage @ref="moduleMessageTop" Message="@_messageContent" Type="@_messageType" Visible="@(!string.IsNullOrEmpty(_messageContent) && _messagePosition == "top")" /> | ||||
|                 @DynamicComponent | ||||
|                 @if (_progressIndicator) | ||||
|                 { | ||||
|                     <div class="app-progress-indicator"></div> | ||||
|                 } | ||||
|                 @if (!string.IsNullOrEmpty(_messageContent) && _messagePosition == "bottom") | ||||
|                 { | ||||
|                     <ModuleMessage Message="@_messageContent" Type="@_messageType" /> | ||||
|                 } | ||||
|                 <ModuleMessage @ref="moduleMessageBottom" Message="@_messageContent" Type="@_messageType" Visible="@(!string.IsNullOrEmpty(_messageContent) && _messagePosition == "bottom")" /> | ||||
|             } | ||||
|         } | ||||
|         else | ||||
| @ -47,6 +41,8 @@ | ||||
|     private string _messagePosition; | ||||
|     private bool _progressIndicator = false; | ||||
|     private string _error; | ||||
|     private ModuleMessage moduleMessageTop; | ||||
|     private ModuleMessage moduleMessageBottom; | ||||
|  | ||||
|     [Parameter] | ||||
|     public SiteState SiteState { get; set; } | ||||
| @ -111,19 +107,20 @@ | ||||
|         _messageType = type; | ||||
|         _messagePosition = position; | ||||
|         _progressIndicator = false; | ||||
|         StateHasChanged(); | ||||
|  | ||||
|         Refresh(); | ||||
|     } | ||||
|  | ||||
|     public void ShowProgressIndicator() | ||||
|     { | ||||
|         _progressIndicator = true; | ||||
|         StateHasChanged(); | ||||
|         Refresh(); | ||||
|     } | ||||
|  | ||||
|     public void HideProgressIndicator() | ||||
|     { | ||||
|         _progressIndicator = false; | ||||
|         StateHasChanged(); | ||||
|         Refresh(); | ||||
|     } | ||||
|  | ||||
|     private void DismissMessage() | ||||
| @ -131,6 +128,15 @@ | ||||
|         _messageContent = ""; | ||||
|     } | ||||
|  | ||||
|     private void Refresh() | ||||
|     { | ||||
|         var messageTopVisible = !string.IsNullOrEmpty(_messageContent) && _messagePosition == "top"; | ||||
|         var messageBottomVisible = !string.IsNullOrEmpty(_messageContent) && _messagePosition == "bottom"; | ||||
|  | ||||
|         moduleMessageTop.RefreshMessage(_messageContent, _messageType, messageTopVisible); | ||||
|         moduleMessageBottom.RefreshMessage(_messageContent, _messageType, messageBottomVisible); | ||||
|     } | ||||
|  | ||||
|     protected override async Task OnErrorAsync(Exception exception) | ||||
|     { | ||||
|         // retrieve friendly localized error | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Ben
					Ben