From 958e60e85b55fe89dc4ede7dd81c3d04af3889c6 Mon Sep 17 00:00:00 2001 From: Alex Hoyau Date: Fri, 24 Aug 2018 19:45:45 +0200 Subject: [PATCH] single service mode closes #62 --- src/js/CloudExplorer.jsx | 9 +++++++++ src/js/UnifileService.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/js/CloudExplorer.jsx b/src/js/CloudExplorer.jsx index 77ad81c..0a3d87e 100644 --- a/src/js/CloudExplorer.jsx +++ b/src/js/CloudExplorer.jsx @@ -162,6 +162,15 @@ export default class CloudExplorer extends React.Component { files, loading: false }); + // the first display, single service mode, try to enter + // this is useful when CE is used by hosting companies to display the user files, and the user has logged in their system + if(!this.initDone && files.length === 1 && path.length === 0/* && files[0].isLoggedIn === true*/) { + this.unifile.cd([files[0].name], true) + .then(path => { + this.props.onCd(path); + }); + } + this.initDone = true; } }) .catch((e) => this.onUnifileError(e)); diff --git a/src/js/UnifileService.js b/src/js/UnifileService.js index da0061a..e65009e 100644 --- a/src/js/UnifileService.js +++ b/src/js/UnifileService.js @@ -124,9 +124,9 @@ export default class UnifileService { }); } - cd (path) { + cd (path, preventAuth=false) { return new Promise((resolve, reject) => { - if (path.length === 1 && path[0] !== this.currentPath[0]) { + if (!preventAuth && path.length === 1 && path[0] !== this.currentPath[0]) { this.auth(path[0]) .then(() => { this.currentPath = path;