Commit ecb7c534 authored by Eric Eastwood's avatar Eric Eastwood
parent f1e1113b
...@@ -42,19 +42,20 @@ const RepoSidebar = { ...@@ -42,19 +42,20 @@ const RepoSidebar = {
file.loading = false; file.loading = false;
} else { } else {
Service.url = file.url; Service.url = file.url;
// I need to refactor this to do the `then` here. Helper.getContent(file)
// Not a callback. For now this is good enough. .then(() => {
// it works. file.loading = false;
Helper.getContent(file, () => { Helper.scrollTabsRight();
file.loading = false; })
Helper.scrollTabsRight(); .catch(Helper.loadingError);
});
} }
}, },
goToPreviousDirectoryClicked(prevURL) { goToPreviousDirectoryClicked(prevURL) {
Service.url = prevURL; Service.url = prevURL;
Helper.getContent(null, () => Helper.scrollTabsRight()); Helper.getContent(null)
.then(() => Helper.scrollTabsRight())
.catch(Helper.loadingError);
}, },
}, },
}; };
......
...@@ -135,14 +135,13 @@ const RepoHelper = { ...@@ -135,14 +135,13 @@ const RepoHelper = {
return isRoot; return isRoot;
}, },
getContent(treeOrFile, cb) { getContent(treeOrFile) {
let file = treeOrFile; let file = treeOrFile;
// const loadingData = RepoHelper.setLoading(true); // const loadingData = RepoHelper.setLoading(true);
return Service.getContent() return Service.getContent()
.then((response) => { .then((response) => {
const data = response.data; const data = response.data;
// RepoHelper.setLoading(false, loadingData); // RepoHelper.setLoading(false, loadingData);
if (cb) cb();
Store.isTree = RepoHelper.isTree(data); Store.isTree = RepoHelper.isTree(data);
if (!Store.isTree) { if (!Store.isTree) {
if (!file) file = data; if (!file) file = data;
......
...@@ -64,9 +64,10 @@ describe('RepoSidebar', () => { ...@@ -64,9 +64,10 @@ describe('RepoSidebar', () => {
describe('methods', () => { describe('methods', () => {
describe('fileClicked', () => { describe('fileClicked', () => {
it('should fetch data for new file', () => { it('should fetch data for new file', () => {
spyOn(Helper, 'getContent'); spyOn(Helper, 'getContent').and.callThrough();
const file1 = { const file1 = {
id: 0, id: 0,
url: '',
}; };
RepoStore.files = [file1]; RepoStore.files = [file1];
RepoStore.isRoot = true; RepoStore.isRoot = true;
...@@ -74,7 +75,7 @@ describe('RepoSidebar', () => { ...@@ -74,7 +75,7 @@ describe('RepoSidebar', () => {
vm.fileClicked(file1); vm.fileClicked(file1);
expect(Helper.getContent).toHaveBeenCalledWith(file1, jasmine.any(Function)); expect(Helper.getContent).toHaveBeenCalledWith(file1);
}); });
it('should hide files in directory if already open', () => { it('should hide files in directory if already open', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment