diff --git a/src/client/web/src/components/browser.tsx b/src/client/web/src/components/browser.tsx index 4bfab54..7edd132 100644 --- a/src/client/web/src/components/browser.tsx +++ b/src/client/web/src/components/browser.tsx @@ -192,10 +192,10 @@ export class Browser extends React.Component { updater() .setItems(dirPath) .then(() => { - updater().listSharings(); + return updater().listSharings(); }) .then(() => { - updater().setSharing(dirPath.join("/")); + return updater().isSharing(dirPath.join("/")); }) .then(() => { this.update(updater().setBrowser); @@ -248,8 +248,12 @@ export class Browser extends React.Component { if (!ok) { alert("failed to enable sharing"); } else { - this.listSharings(); + updater().setSharing(true); + return this.listSharings(); } + }) + .then(() => { + this.props.update(updater().setBrowser); }); }; @@ -260,8 +264,12 @@ export class Browser extends React.Component { if (!ok) { alert("failed to disable sharing"); } else { - this.listSharings(); + updater().setSharing(false); + return this.listSharings(); } + }) + .then(() => { + this.props.update(updater().setBrowser); }); }; diff --git a/src/client/web/src/components/browser.updater.ts b/src/client/web/src/components/browser.updater.ts index e4092b2..d5272c7 100644 --- a/src/client/web/src/components/browser.updater.ts +++ b/src/client/web/src/components/browser.updater.ts @@ -65,16 +65,20 @@ export class Updater { }; deleteSharing = async (dirPath: string): Promise => { - const resp = await this.filesClient.addSharing(dirPath); + const resp = await this.filesClient.deleteSharing(dirPath); return resp.status === 200; }; - setSharing = async (dirPath: string): Promise => { + isSharing = async (dirPath: string): Promise => { const resp = await this.filesClient.isSharing(dirPath); this.props.isSharing = resp.status === 200; return resp.status === 200; // TODO: differentiate 404 and error }; + setSharing = (shared: boolean) => { + this.props.isSharing = shared; + }; + listSharings = async (): Promise => { const resp = await this.filesClient.listSharings(); this.props.sharings = diff --git a/src/client/web/src/components/pane_login.tsx b/src/client/web/src/components/pane_login.tsx index 1a2426b..e3a490d 100644 --- a/src/client/web/src/components/pane_login.tsx +++ b/src/client/web/src/components/pane_login.tsx @@ -140,7 +140,7 @@ export class AuthPane extends React.Component { return BrowserUpdater().refreshUploadings(); }) .then(() => { - return BrowserUpdater().setSharing( + return BrowserUpdater().isSharing( BrowserUpdater().props.dirPath.join("/") ); }) diff --git a/src/client/web/src/components/state_mgr.tsx b/src/client/web/src/components/state_mgr.tsx index 34d7a12..7b1f0fb 100644 --- a/src/client/web/src/components/state_mgr.tsx +++ b/src/client/web/src/components/state_mgr.tsx @@ -41,7 +41,7 @@ export class StateMgr extends React.Component { return BrowserUpdater().initUploads(); }) .then(() => { - return BrowserUpdater().setSharing( + return BrowserUpdater().isSharing( BrowserUpdater().props.dirPath.join("/") ); })