mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-11 01:39:18 +02:00
24 lines
443 B
TypeScript
24 lines
443 B
TypeScript
import { Pipe, PipeTransform } from "@angular/core";
|
|
|
|
interface User {
|
|
name?: string;
|
|
email?: string;
|
|
}
|
|
|
|
@Pipe({
|
|
name: "userName",
|
|
})
|
|
export class UserNamePipe implements PipeTransform {
|
|
transform(user?: User): string {
|
|
if (user == null) {
|
|
return null;
|
|
}
|
|
|
|
if (user.name == null && user.email == null) {
|
|
return null;
|
|
}
|
|
|
|
return user.name == null || user.name.trim() === "" ? user.email : user.name;
|
|
}
|
|
}
|