All files / app/reducers commits.ts

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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115    13x 70x       3x   67x       13x 71x   1x   1x   69x       13x 70x   1x   69x       13x 70x   1x   1x   68x       13x 53x           53x       13x 53x           53x       13x 53x           53x       13x 53x           53x     13x 53x           53x     13x 53x           53x     13x 53x       53x    
import { ActionTypes } from 'app/actions/ActionTypes';
 
export const selectedPath = (state = '', action: any) => {
  switch (action.type) {
    case ActionTypes.SELECT_PATH:
    case ActionTypes.REQUEST_COMMITS:
    case ActionTypes.RECEIVE_COMMITS:
      return action.selectedPath;
    default:
      return state;
  }
};
 
export const commits = (state = [], action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return [];
    case ActionTypes.RECEIVE_COMMITS:
      return state.concat(action.commits);
    default:
      return state;
  }
};
 
export const highlightedCommitIds = (state = '', action: any) => {
  switch (action.type) {
    case ActionTypes.HIGHLIGHT_COMMITS:
      return action.commitIds;
    default:
      return state;
  }
};
 
export const isFetching = (state = false, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return true;
    case ActionTypes.RECEIVED_All_COMMITS:
      return false;
    default:
      return state;
  }
};
 
export const totalCommits = (state = 0, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return 0;
    case ActionTypes.RECEIVE_COMMIT_RANGE:
      return action.commitRange.count;
    default:
      return state;
  }
};
 
export const earliestCommitDate = (state = null, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return null;
    case ActionTypes.RECEIVE_COMMIT_RANGE:
      return action.commitRange.firstCommit.authorDate;
    default:
      return state;
  }
};
 
export const latestCommitDate = (state = 0, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return null;
    case ActionTypes.RECEIVE_COMMIT_RANGE:
      return action.commitRange.lastCommit.authorDate;
    default:
      return state;
  }
};
 
export const hasUncommittedChanges = (state = null, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return null;
    case ActionTypes.RECEIVE_COMMIT_RANGE:
      return action.commitRange.hasUncommittedChanges;
  }
  return state;
};
 
export const existsLocally = (state = null, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return null;
    case ActionTypes.RECEIVE_COMMIT_RANGE:
      return action.commitRange.existsLocally;
  }
  return state;
};
 
export const gitRoot = (state = null, action: any) => {
  switch (action.type) {
    case ActionTypes.REQUEST_COMMITS:
      return null;
    case ActionTypes.RECEIVE_COMMIT_RANGE:
      return action.commitRange.gitRoot;
  }
  return state;
};
 
export const isFileSelected = (state = false, action: any) => {
  switch (action.type) {
    case ActionTypes.RECEIVE_COMMITS:
      return action.isFileSelected;
  }
  return state;
};