File size: 509 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { getActions } from '../../helpers/notes';
import getNotes from './get-notes';

export const getIsNoteLiked = ( notesState, note ) => {
	const noteLikes = notesState.noteLikes;

	if ( noteLikes.hasOwnProperty( note.id ) ) {
		return noteLikes[ note.id ];
	}

	const actionMeta = getActions( note );
	const likeProperty = note.meta.ids.comment ? 'like-comment' : 'like-post';

	return actionMeta[ likeProperty ] ?? false;
};

export default ( state, note ) => getIsNoteLiked( getNotes( state ), note );