Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Show remote editors even when there's no open project
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed Feb 15, 2018
1 parent d92eed3 commit d55c052
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/project-view.js
Expand Up @@ -59,12 +59,6 @@ export default class ProjectView extends FuzzyFinderView {
}

async populate () {
if (atom.project.getPaths().length === 0) {
await this.setItems([])
return
}

const localItems = this.projectRelativePathsForFilePaths(this.paths || [])
const remoteEditors = this.teletypeService ? await this.teletypeService.getRemoteEditors() : []
const remoteItems = remoteEditors.map((remoteEditor) => {
return {
Expand All @@ -74,6 +68,13 @@ export default class ProjectView extends FuzzyFinderView {
ownerGitHubUsername: remoteEditor.hostGitHubUsername
}
})

if (atom.project.getPaths().length === 0) {
await this.setItems(remoteItems)
return
}

const localItems = this.projectRelativePathsForFilePaths(this.paths || [])
await this.setItems(remoteItems.concat(localItems))

if (this.reloadPaths) {
Expand Down
20 changes: 20 additions & 0 deletions spec/project-view-spec.js
Expand Up @@ -37,4 +37,24 @@ describe('ProjectView', () => {
{uri: file2Path, filePath: file2Path, label: 'b'}
])
})

it('shows remote editors even when there is no open project', async () => {
const projectView = new ProjectView()

atom.project.setPaths([])
projectView.setTeletypeService({
async getRemoteEditors () {
return [
{uri: 'remote1-uri', path: 'remote1-path', hostGitHubUsername: 'user-1'},
{uri: 'remote2-uri', path: 'remote2-path', hostGitHubUsername: 'user-2'}
]
}
})

await projectView.toggle()
expect(projectView.items).toEqual([
{uri: 'remote1-uri', filePath: 'remote1-path', label: '@user-1: remote1-path', ownerGitHubUsername: 'user-1'},
{uri: 'remote2-uri', filePath: 'remote2-path', label: '@user-2: remote2-path', ownerGitHubUsername: 'user-2'}
])
})
})

0 comments on commit d55c052

Please sign in to comment.