From 65da92aece7ac78a493b19d07d8a02c7ccbdb54d Mon Sep 17 00:00:00 2001 From: hexxa Date: Sun, 23 Jan 2022 18:51:01 +0800 Subject: [PATCH] fix(state_updater): share is not enabled, move to initControls --- .../src/components/__test__/state_mgr.test.tsx | 6 ++---- src/client/web/src/components/state_updater.ts | 17 +++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/client/web/src/components/__test__/state_mgr.test.tsx b/src/client/web/src/components/__test__/state_mgr.test.tsx index 879a4b1..31943a8 100644 --- a/src/client/web/src/components/__test__/state_mgr.test.tsx +++ b/src/client/web/src/components/__test__/state_mgr.test.tsx @@ -161,9 +161,7 @@ describe("State Manager", () => { }; usersCl.isAuthed = jest .fn() - .mockReturnValue( - makePromise({ status: 401, statusText: "", data: {} }) - ); + .mockReturnValue(makePromise({ status: 401, statusText: "", data: {} })); usersCl.self = jest.fn().mockReturnValue(makePromise(mockSelfResp)); const coreState = newState(); @@ -187,7 +185,7 @@ describe("State Manager", () => { expect(coreState.filesInfo.dirPath.join("/")).toEqual(sharingPath); expect(coreState.filesInfo.isSharing).toEqual(true); expect(coreState.filesInfo.items).toEqual( - List(filesResps.listHomeMockResp.data.metadatas) + List(filesResps.listMockResp.data.metadatas) ); expect(coreState.sharingsInfo.sharings).toEqual(Map()); expect(coreState.uploadingsInfo.uploadings).toEqual(List([])); diff --git a/src/client/web/src/components/state_updater.ts b/src/client/web/src/components/state_updater.ts index 773852e..954e601 100644 --- a/src/client/web/src/components/state_updater.ts +++ b/src/client/web/src/components/state_updater.ts @@ -420,16 +420,8 @@ export class Updater { if (shareDir !== "") { // in sharing mode const dirPath = List(shareDir.split("/")); - this.props.ui.control.controls = this.props.ui.control.controls.set( - sharingCtrl, - ctrlOn - ); this.props.filesInfo.dirPath = dirPath; } else { - this.props.ui.control.controls = this.props.ui.control.controls.set( - sharingCtrl, - ctrlOff - ); this.props.filesInfo.dirPath = List([]); } @@ -506,6 +498,14 @@ export class Updater { return paramMap; }; + initControls = async (params: Map) => { + const shareDir = params.get(shareDirQuery); + this.props.ui.control.controls = this.props.ui.control.controls.set( + sharingCtrl, + shareDir !== "" ? ctrlOn : ctrlOff + ); + }; + initAuth = async (): Promise => { const isAuthedStatus = await this.syncIsAuthed(); if (isAuthedStatus !== "") { @@ -537,6 +537,7 @@ export class Updater { return initClientCfgStatus; } + this.initControls(paramMap); this.initUITree(); const isInSharingMode = paramMap.get(shareDirQuery) !== "";