MCPcopy
hub / github.com/JoelOtter/kajero / handleChange

Function handleChange

src/js/reducers/notebookReducer.js:226–248  ·  view source on GitHub ↗
(currentState, newState)

Source from the content-addressed store, hash-verified

224 * Handles changes, if they exist, by pushing to the undo stack.
225 */
226function handleChange(currentState, newState) {
227 if (currentState.equals(newState)) {
228 return newState;
229 }
230 let result = newState.set(
231 'undoStack',
232 newState.get('undoStack').push(currentState.remove('undoStack'))
233 ).deleteIn(
234 ['metadata', 'gistUrl']
235 ).setIn(
236 ['metadata', 'created'],
237 new Date()
238 );
239
240 // If it's the first change, update the parent link.
241 if (currentState.get('undoStack').size === 0) {
242 result = result.setIn(['metadata', 'original'], Immutable.fromJS({
243 title: currentState.getIn(['metadata', 'title']),
244 url: location.href
245 }));
246 }
247 return result;
248}
249
250function undo(state) {
251 if (state.get('undoStack').size === 0) {

Callers 1

notebookFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected