-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da9693a
commit 6794e53
Showing
24 changed files
with
200 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
...ages/giterm/app/renderer/lib/profiling.js → ...ages/giterm/app/renderer/lib/profiling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
...iterm/app/renderer/store/graph/actions.js → ...iterm/app/renderer/store/graph/actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { GRAPH_UPDATED, graphUpdated } from './actions' | ||
|
||
import { GraphResponse } from '@giterm/gitgraph' | ||
import { Holistic } from './types' | ||
|
||
export interface GraphReducer { | ||
holistics: Holistic | ||
nodes: GraphResponse['nodes'] | ||
links: GraphResponse['links'] | ||
rehydrationPackage?: GraphResponse['rehydrationPackage'] | ||
width: number | ||
} | ||
|
||
const initialState: GraphReducer = { | ||
holistics: { digest: undefined }, | ||
nodes: [], | ||
links: [], | ||
rehydrationPackage: undefined, | ||
width: 0 | ||
} | ||
|
||
export function reducer(state = initialState, action: any): GraphReducer { | ||
switch (action.type) { | ||
case GRAPH_UPDATED: { | ||
const { graph, holistics } = action as ReturnType<typeof graphUpdated> | ||
|
||
return { | ||
holistics: holistics, | ||
nodes: graph.nodes, | ||
links: graph.links, | ||
rehydrationPackage: graph.rehydrationPackage, | ||
width: graph.nodes.reduce((max, node) => Math.max(node.column + 1, max), 3), | ||
} | ||
} | ||
|
||
default: | ||
return state | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { takeEvery, put, select } from 'redux-saga/effects' | ||
|
||
import { graphUpdateSkipped, graphUpdated } from './actions' | ||
import { commitsToGraph } from '@giterm/gitgraph' | ||
import { COMMITS_UPDATED } from 'app/store/commits/actions' | ||
import { sentrySafeWrapper } from 'app/store/helpers' | ||
import { measure } from 'app/lib/profiling' | ||
import { State } from 'app/store' | ||
|
||
function* recalculateGraph(): any { | ||
const { commits, digest } = yield select((state) => state.commits) | ||
|
||
const currentGraph: State['graph'] = yield select((state) => state.graph) | ||
|
||
const commitsUnchanged = digest === currentGraph.holistics.digest | ||
if (commitsUnchanged || !commits || !commits.length) { | ||
yield put(graphUpdateSkipped()) | ||
return | ||
} | ||
|
||
const graph = measure('calculate-graph', () => | ||
commitsToGraph( | ||
commits, | ||
), | ||
) | ||
|
||
yield put(graphUpdated({ | ||
digest | ||
}, graph)) | ||
} | ||
|
||
export function* watch() { | ||
yield takeEvery([COMMITS_UPDATED], sentrySafeWrapper(recalculateGraph)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type Holistic = { | ||
digest?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Remote } from '@giterm/git' | ||
|
||
export const REMOTES_UPDATED = 'remotes/updated' | ||
|
||
export const remotesUpdated = (remotes: Remote[]) => ({ | ||
type: REMOTES_UPDATED, | ||
remotes, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Remote } from '@giterm/git' | ||
import { updateReducer } from 'app/store/helpers' | ||
import { REMOTES_UPDATED } from './actions' | ||
|
||
export const reducer = updateReducer<Remote[]>(REMOTES_UPDATED, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { StatusFile } from '@giterm/git' | ||
|
||
export const STATUS_UPDATED = 'status/updated' | ||
export const statusUpdated = ( | ||
files: StatusFile[], | ||
state: string, | ||
headSHA: string, | ||
) => ({ | ||
type: STATUS_UPDATED, | ||
payload: { | ||
files, | ||
state, | ||
headSHA, | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { StatusFile } from '@giterm/git' | ||
import { updateReducer } from 'app/store/helpers' | ||
import { STATUS_UPDATED } from './actions' | ||
|
||
export interface StatusReducer { | ||
files: StatusFile[], | ||
state: string, | ||
headSHA: string, | ||
} | ||
|
||
const initialState = { | ||
files: [], | ||
state: '', | ||
headSHA: '', | ||
} | ||
|
||
export const reducer = updateReducer<StatusReducer>(STATUS_UPDATED, initialState) |
Oops, something went wrong.