Merge pull request #3738 from sbwalker/dev

optrimization to eliminate file lookup in Logo control
This commit is contained in:
Shaun Walker 2024-02-06 11:26:47 -05:00 committed by GitHub
commit cf9ef281ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,24 +1,11 @@
@namespace Oqtane.Themes.Controls @namespace Oqtane.Themes.Controls
@inherits ThemeControlBase @inherits ThemeControlBase
@inject IFileService FileService
@if (file != null) @if (PageState.Site.LogoFileId != null)
{ {
<span class="app-logo"> <span class="app-logo">
<a href="@PageState.Alias.Path"> <a href="@PageState.Alias.Path">
<img class="img-fluid" src="@file.Url" alt="@PageState.Site.Name" /> <img class="img-fluid" src="@Utilities.FileUrl(PageState.Alias, PageState.Site.LogoFileId.Value)" alt="@PageState.Site.Name" />
</a> </a>
</span> </span>
}
@code {
private File file = null;
protected override async Task OnParametersSetAsync()
{
if (PageState.Site.LogoFileId != null && file?.FileId != PageState.Site.LogoFileId.Value)
{
file = await FileService.GetFileAsync(PageState.Site.LogoFileId.Value);
}
}
} }