File size: 808 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
import getNotes from './get-notes';

export const getIsNoteRead = ( notesState, note ) => {
	const localReads = notesState.noteReads;

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

	// this absolutely needs to be redone but is not happening at
	// the time of moving it from rest-client to keep the PR and
	// changeset small. the persistent state should come through
	// Redux middleware instead of operating at such a granular
	// layer but introducing serializers is enough for its own PR
	try {
		const storedRead = localStorage.getItem( `note_read_status_${ note.id }` );
		if ( null !== storedRead && '1' === storedRead ) {
			return true;
		}
	} catch ( e ) {}

	return !! note.read;
};

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