Refactor categories into rootListing

This uses proper paths with slashes everywhere, and lists documents
instead of just folders for root.
This commit is contained in:
2017-11-12 20:46:31 +01:00
parent 287a999207
commit 2008ed5634
9 changed files with 67 additions and 32 deletions

View File

@@ -11,7 +11,7 @@ export default Service.extend({
connecting: true,
connected: false,
client: null,
categories: null,
rootListing: null,
setup: function() {
const rs = new RemoteStorage({
@@ -72,16 +72,9 @@ export default Service.extend({
this.set('client', rs.scope('/'));
}.on('init'),
fetchCategories() {
const client = this.get('client');
client.getListing('').then(listing => {
let dirnames = Object.keys(listing);
let categories = dirnames.reject(i => i.substr(-1) !== '/')
.map(i => i.replace('/', ''))
.sort();
this.set('categories', categories);
fetchRootListing() {
this.fetchListing('').then(items => {
this.set('rootListing', items.sortBy('name'));
});
},