Skip to content

Commit 2d17c52

Browse files
authored
fix(repo): fix regressions of staring repository and viewing issues by deleted users (#855)
* fix(repo): Use the right repository entity name * fix(issue): Fix issue screen * fix(repo): Fill ghost user if the account is deleted
1 parent d1bb088 commit 2d17c52

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/api/schemas/gql-repos.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
11
import { schema } from 'normalizr';
22

3+
const ghostUser = {
4+
login: 'ghost',
5+
avatarUrl: 'https://avatars3.githubusercontent.com/u/10137?v=4',
6+
type: 'User',
7+
};
8+
9+
const fillGhostUser = obj => ({
10+
...obj,
11+
nodes: obj.nodes.map(node => ({
12+
...node,
13+
author: node.author || ghostUser,
14+
})),
15+
});
16+
317
export const gqlRepoSchema = new schema.Entity(
4-
'repos',
18+
'gqlRepos',
519
{},
620
{
721
idAttribute: ({ repository }) => {
822
return repository.nameWithOwner.toLowerCase();
923
},
1024
processStrategy: ({ repository }) => ({
1125
...repository,
26+
openIssuesPreview: fillGhostUser(repository.openIssuesPreview),
27+
openPullRequestsPreview: fillGhostUser(
28+
repository.openPullRequestsPreview
29+
),
30+
issues: fillGhostUser(repository.issues),
31+
pullRequests: fillGhostUser(repository.pullRequests),
1232
permissions: {
1333
admin: repository.viewerPermission === 'ADMIN',
14-
push: repository.viewerPermission === 'ADMIN' || repository.viewerPermission === 'WRITE',
34+
push:
35+
repository.viewerPermission === 'ADMIN' ||
36+
repository.viewerPermission === 'WRITE',
1537
},
1638
full_name: repository.nameWithOwner,
1739
webUrl: `https://github.com/${repository.nameWithOwner}`,

src/issue/screens/issue.screen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const mapStateToProps = (state, ownProps) => {
6161
isPostingComment,
6262
isDeletingComment,
6363
},
64-
entities: { users, repos, issues, issueTimelineItems },
64+
entities: { users, gqlRepos, issues, issueTimelineItems },
6565
pagination: { REPOS_GET_CONTRIBUTORS, REPOS_GET_ISSUE_TIMELINE },
6666
} = state;
6767

@@ -79,7 +79,7 @@ const mapStateToProps = (state, ownProps) => {
7979
return {
8080
locale,
8181
authUser: user,
82-
repository: repos[issueRepository],
82+
repository: gqlRepos[issueRepository],
8383
contributors: (
8484
REPOS_GET_CONTRIBUTORS[issueRepository] || { ids: [] }
8585
).ids.map(id => users[id]),

src/repository/screens/repository.screen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import { getCommits } from '../repository.action';
2626
const mapStateToProps = (state, ownProps) => {
2727
const {
2828
auth: { user, locale },
29-
entities: { users, repos },
29+
entities: { users, gqlRepos },
3030
pagination: { REPOS_GET_CONTRIBUTORS },
3131
} = state;
3232

3333
const repoId = ownProps.navigation.state.params.repoId;
3434

35-
const repository = repos[repoId];
35+
const repository = gqlRepos[repoId];
3636

3737
const contributorsPagination = REPOS_GET_CONTRIBUTORS[repoId] || {
3838
ids: [],

0 commit comments

Comments
 (0)