react-code-dataset / wp-calypso /apps /notifications /src /panel /state /action-middleware /ui /index.js
react-code-dataset / wp-calypso /apps /notifications /src /panel /state /action-middleware /ui /index.js
Download wp-calypso/apps/notifications/src/panel/state/action-middleware/ui/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/notifications/src/panel/state/action-middleware/ui/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/apps/notifications/src/panel/state/action-middleware/ui/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/notifications/src/panel/state/action-middleware/ui/index.js
1.09 kB
| import { findNextNoteId } from '../../../templates'; | |
| import * as types from '../../action-types'; | |
| import actions from '../../actions'; | |
| import getAllNotes from '../../selectors/get-all-notes'; | |
| import getIsNoteHidden from '../../selectors/get-is-note-hidden'; | |
| export const advanceToNextNote = ( { dispatch, getState }, { noteId } ) => { | |
| const state = getState(); | |
| // move to next note in the sequence… | |
| const nextNoteId = findNextNoteId( | |
| noteId, | |
| getAllNotes( state ).filter( ( { id } ) => ! getIsNoteHidden( state, id ) ) | |
| ); | |
| // if the window is wide enough and we have a next node | |
| // then go ahead and open it | |
| // otherwise go back to the list | |
| if ( nextNoteId && window.innerWidth >= 800 ) { | |
| dispatch( actions.ui.selectNote( nextNoteId ) ); | |
| } else { | |
| dispatch( actions.ui.unselectNote() ); | |
| } | |
| }; | |
| const toggleDrawer = ( { dispatch }, { noteId } ) => | |
| dispatch( actions.ui.setLayout( noteId ? 'widescreen' : 'narrow' ) ); | |
| export default { | |
| [ types.SELECT_NOTE ]: [ toggleDrawer ], | |
| [ types.SPAM_NOTE ]: [ advanceToNextNote ], | |
| [ types.TRASH_NOTE ]: [ advanceToNextNote ], | |
| }; | |