Skip to content

Commit

Permalink
Merge 879a26d into f44bd94
Browse files Browse the repository at this point in the history
  • Loading branch information
Quazia committed May 15, 2019
2 parents f44bd94 + 879a26d commit 9ae6ea1
Showing 1 changed file with 31 additions and 26 deletions.
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

0 comments on commit 9ae6ea1

Please sign in to comment.