export const initialChangesState = { files: [], selectedDiff: null, selectedDiffs: [], available: true, pending: "", error: "" };
export function reduceChangesState(state, action) {
  if (action.type === "session.changed") return initialChangesState;
  if (action.type === "files.started") return { ...state, pending: "files", error: "" };
  if (action.type === "files.loaded") return { ...state, files: action.files, available: action.available, selectedDiff: null, selectedDiffs: [], pending: "", error: "" };
  if (action.type === "files.failed") return { ...state, pending: "", error: "changes_list_failed" };
  if (action.type === "files.pushed") return { ...state, files: action.files };
  if (action.type === "diff.started") return { ...state, pending: "diff", error: "" };
  if (action.type === "diff.loaded") return { ...state, selectedDiff: action.diff, pending: "", error: "" };
  if (action.type === "diff.failed") return { ...state, pending: "", error: "changes_diff_failed" };
  if (action.type === "diffs.started") return { ...state, selectedDiffs: [], pending: "diffs", error: "" };
  if (action.type === "diffs.itemLoaded") return { ...state, selectedDiffs: [...state.selectedDiffs, action.diff] };
  if (action.type === "diffs.loaded") return { ...state, selectedDiffs: action.diffs, pending: "", error: "" };
  return state;
}
