Improve HtmlText module performance

This commit is contained in:
Shaun Walker
2019-08-16 09:49:26 -04:00
parent 9cda80f7e9
commit 0c57813bf8
9 changed files with 128 additions and 38 deletions

View File

@ -28,16 +28,14 @@
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
public override string Title { get { return "Edit Html/Text"; } }
HtmlTextInfo htmltext;
string content;
protected override async Task OnInitializedAsync()
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltextlist != null)
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
htmltext = htmltextlist.FirstOrDefault();
content = htmltext.Content;
}
}
@ -45,6 +43,7 @@
private async Task SaveContent()
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
htmltext.Content = content;

View File

@ -19,10 +19,10 @@
protected override async Task OnParametersSetAsync()
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
content = htmltext.FirstOrDefault().Content;
content = htmltext.Content;
}
}
}

View File

@ -27,13 +27,9 @@ namespace Oqtane.Client.Modules.HtmlText.Services
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "HtmlText"); }
}
public async Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId)
public async Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId)
{
List<HtmlTextInfo> htmltext = await http.GetJsonAsync<List<HtmlTextInfo>>(apiurl);
htmltext = htmltext
.Where(item => item.ModuleId == ModuleId)
.ToList();
return htmltext;
return await http.GetJsonAsync<HtmlTextInfo>(apiurl + "/" + ModuleId.ToString());
}
public async Task AddHtmlTextAsync(HtmlTextInfo htmltext)

View File

@ -6,7 +6,7 @@ namespace Oqtane.Client.Modules.HtmlText.Services
{
public interface IHtmlTextService
{
Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId);
Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId);
Task AddHtmlTextAsync(HtmlTextInfo htmltext);