Modify HarborDatetimePipe to pure pipe to improve performance (#16906)

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2022-05-25 10:43:29 +08:00 committed by GitHub
parent e33197a487
commit a9063d240d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 10 deletions

View File

@ -1,7 +1,6 @@
<clr-header class="header-5 header" [attr.style]="getBgColor()">
<div class="branding">
<a href="javascript:void(0)" class="nav-link" (click)="homeAction()">
<!-- <clr-icon shape="vm-bug" *ngIf="!customStyle?.headerLogo"></clr-icon> -->
<img
[attr.src]="'images/' + customStyle?.product?.logo"
*ngIf="customStyle?.product?.logo; else elseBlock"

View File

@ -192,6 +192,8 @@ export class NavigatorComponent implements OnInit {
DEFAULT_DATETIME_RENDERING_LOCALSTORAGE_KEY,
datetime
);
// have to reload,as HarborDatetimePipe is pure pipe
window.location.reload();
}
// Handle the home action

View File

@ -22,7 +22,7 @@ const formatTransformers: Record<
@Pipe({
name: 'harborDatetime',
pure: false,
pure: true,
})
export class HarborDatetimePipe implements PipeTransform {
transform(value: any, format?: string): string {

View File

@ -297,16 +297,10 @@ export function getDatetimeRendering(): DatetimeRendering {
const savedDatetimeRendering = localStorage.getItem(
DEFAULT_DATETIME_RENDERING_LOCALSTORAGE_KEY
);
if (isDatetimeRendering(savedDatetimeRendering)) {
if (savedDatetimeRendering && isDatetimeRendering(savedDatetimeRendering)) {
return savedDatetimeRendering;
} else {
console.warn(
`Invalid saved datetime rendering setting ${JSON.stringify(
savedDatetimeRendering
)}; defaulting to ${JSON.stringify(DefaultDatetimeRendering)}.`
);
return DefaultDatetimeRendering;
}
return DefaultDatetimeRendering;
}
function isDatetimeRendering(x: unknown): x is DatetimeRendering {