mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-29 19:11:24 +01:00
Modify HarborDatetimePipe to pure pipe to improve performance (#16906)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
e33197a487
commit
a9063d240d
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user