Skip to content

Commit a5e061a

Browse files
arthurdennerCompuIves
authored andcommitted
fix(git): Properly update Git integration UI after a commit (codesandbox#2042)
* refactor(modules/git): Use undefined instead of null to originalGitChanges state * refactor(git): Handle undefined values with defaultProps * fix(git): Properly update Git integration UI after a commit * refactor(modules/git): Use null instead of undefined to originalGitChanges state Use of undefined raises a warning in mobx-state-tree * fix(sequences/git): Fetch Git changes after finishing a commit
1 parent ffce4e9 commit a5e061a

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/Git/Changes/Changes.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ export const Changes = ({ changes, color, hideColor, Icon, title }) => (
1818
))}
1919
</>
2020
);
21+
22+
Changes.defaultProps = {
23+
changes: [],
24+
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/Git/Git.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ export const Git = observer(() => {
7474

7575
<Margin bottom={0}>
7676
<WorkspaceSubtitle>
77-
Changes ({gitChanges ? changeCount : '...'})
77+
Changes ({isFetching ? '...' : changeCount})
7878
</WorkspaceSubtitle>
7979

80-
{!isFetching && gitChanges ? (
80+
{!isFetching ? (
8181
<Margin top={1}>
82-
<TotalChanges gitChanges={gitChanges} />
82+
<TotalChanges gitChanges={gitChanges || {}} />
8383

8484
{changeCount > 0 ? (
8585
<Margin top={1}>

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/Git/TotalChanges/TotalChanges.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ export const TotalChanges = ({ gitChanges, hideColor }: Props) => (
1616
<Deleted changes={gitChanges.deleted} hideColor={hideColor} />
1717
</>
1818
);
19+
20+
TotalChanges.defaultProps = {
21+
gitChanges: {},
22+
};

packages/app/src/app/store/modules/git/sequences.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { set, when, wait } from 'cerebral/operators';
22
import { state, props, string } from 'cerebral/tags';
3+
import { fetchGitChanges } from '../../sequences';
34
import * as actions from './actions';
45

56
export const changeRepoTitle = [
@@ -53,7 +54,7 @@ export const createCommit = [
5354
},
5455
set(state`git.subject`, ''),
5556
set(state`git.description`, ''),
56-
set(state`git.originalGitChanges`, null),
57+
fetchGitChanges,
5758
];
5859

5960
export const createPr = [

0 commit comments

Comments
 (0)