Improve connection handling

* Clear directory data on disconnect
* Clear path URL param on disconnect
* Don't try to fetch dir listing when starting app disconnected
This commit is contained in:
2017-12-22 12:52:48 +01:00
parent b49cb5c50e
commit e865ffe073
4 changed files with 25 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
import EmberObject from '@ember/object';
import { computed, observer } from '@ember/object';
import Service from '@ember/service';
import RemoteStorage from 'npm:remotestoragejs';
import Widget from 'npm:remotestorage-widget';
@@ -10,6 +11,7 @@ export default Service.extend({
widget: null,
connecting: true,
connected: false,
disconnected: computed.not('connected'),
client: null,
rootListing: null,
@@ -72,6 +74,14 @@ export default Service.extend({
this.set('client', rs.scope('/'));
}.on('init'),
connectedChange: observer('connected', function() {
if (this.get('connected')) {
this.fetchRootListing();
} else {
this.set('rootListing', null);
}
}),
fetchRootListing() {
this.fetchListing('').then(items => {
this.set('rootListing', items.sortBy('name'));