Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projects hot fix - resolve 1hive issues #910

Merged
merged 3 commits into from
May 15, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 31 additions & 26 deletions apps/projects/app/store/helpers/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,37 @@ const getRepoData = repo => {
}

const loadRepoData = id => {
return new Promise(resolve => {
app.call('getRepo', id).subscribe(response => {
return new Promise(async(resolve) => {
app.call('isRepoAdded', id).subscribe(isAddedResponse => {
if(!isAddedResponse) {
return resolve({ repoRemoved: true })
}
app.call('getRepo', id).subscribe(response => {
// handle repo removed case
if (!response) return resolve({ repoRemoved: true })

const _repo = toAscii(id)
getRepoData(_repo).then(({ node }) => {
const commits = node.defaultBranchRef
? node.defaultBranchRef.target.history.totalCount
: 0
const description = node.description
? node.description
: '(no description available)'
const metadata = {
name: node.name,
url: node.url,
description: description,
// TODO: disabled for now (apparently needs push permission on the repo to work)
collaborators: 0, //node.collaborators.totalCount,
commits,
}
return resolve({
_repo,
index: response.index,
metadata,
repoRemoved: false,
if (!response) return resolve({ repoRemoved: true })

const _repo = toAscii(id)
getRepoData(_repo).then(({ node }) => {
const commits = node.defaultBranchRef
? node.defaultBranchRef.target.history.totalCount
: 0
const description = node.description
? node.description
: '(no description available)'
const metadata = {
name: node.name,
url: node.url,
description: description,
// TODO: disabled for now (apparently needs push permission on the repo to work)
collaborators: 0, //node.collaborators.totalCount,
commits,
}
return resolve({
_repo,
index: response.index,
metadata,
repoRemoved: false,
})
})
})
})
Expand Down Expand Up @@ -130,7 +135,7 @@ const updateState = async (state, id, transform) => {
}

// if the user hasn't logged in to github, add the repos to a queue to load later
unloadedRepoQueue.push(id)
if(!unloadedRepoQueue.includes(id)) unloadedRepoQueue.push(id)
return state
} catch (err) {
console.error(
Expand Down