File size: 904 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { getCurrentUserId } from 'calypso/state/current-user/selectors';

import 'calypso/state/gravatar-status/init';

/**
 * Returns true if we're currently uploading a Gravatar
 * @param {Object} state - The state
 * @returns {boolean} - If uploading a Gravatar
 */
export function isCurrentUserUploadingGravatar( state ) {
	return state.gravatarStatus.isUploading;
}

/**
 * Returns the temp Gravatar if it exists and
 * the current user ID is passed in, otherwise false
 * @param {Object} state - The state
 * @param {number} userId - The ID of the user we're checking
 * @returns {string|boolean} - The temp Gravatar string, or false
 */
export function getUserTempGravatar( state, userId ) {
	return getCurrentUserId( state ) === userId && ( state.gravatarStatus.tempImage ?? false );
}

export const hasGravatar = ( state ) => {
	return !! state.gravatarStatus?.gravatarDetails?.has_gravatar;
};