mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
Extract gravatar URL fn (#2386)
This commit is contained in:
parent
029bb2453e
commit
076ce027ed
@ -1,5 +1,5 @@
|
||||
import gravatarUrl from 'gravatar-url';
|
||||
import Joi from 'joi';
|
||||
import { generateImageUrl } from '../util/generateImageUrl';
|
||||
|
||||
export interface UserData {
|
||||
id: number;
|
||||
@ -79,10 +79,7 @@ export default class User implements IUser {
|
||||
}
|
||||
|
||||
generateImageUrl(): string {
|
||||
return gravatarUrl(this.email || this.username || '' + this.id, {
|
||||
size: 42,
|
||||
default: 'retro',
|
||||
});
|
||||
return generateImageUrl(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
11
src/lib/util/generateImageUrl.ts
Normal file
11
src/lib/util/generateImageUrl.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import gravatarUrl from 'gravatar-url';
|
||||
|
||||
export const generateImageUrl = (user: {
|
||||
email: string;
|
||||
username: string;
|
||||
id: number;
|
||||
}): string =>
|
||||
gravatarUrl(user.email || user.username || String(user.id), {
|
||||
size: 42,
|
||||
default: 'retro',
|
||||
});
|
Loading…
Reference in New Issue
Block a user