Sebastian Kippe e865ffe073 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
2017-12-22 12:54:29 +01:00

38 lines
1.0 KiB
JavaScript

import Controller from '@ember/controller';
import { inject as controller } from '@ember/controller';
import { observer } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import { isPresent } from '@ember/utils';
export default Controller.extend({
application: controller(),
storage: service(),
// connecting: alias('storage.connecting'),
connected: alias('storage.connected'),
rootListing: alias('storage.rootListing'),
currentDirPath: alias('application.currentDirPath'),
queryParams: ['path'],
currentListing: function() {
if (isPresent(this.get('model.currentListing'))) {
return this.get('model.currentListing').sortBy('name');
} else {
return this.get('rootListing');
}
}.property('rootListing.[]', 'model.[]'),
connectedChange: observer('connected', function() {
if (this.get('connected')) {
// console.debug('connectedChange connected');
} else {
this.set('model', {});
this.set('path', null);
}
}),
});