fix(state_updater): share is not enabled, move to initControls

This commit is contained in:
hexxa 2022-01-23 18:51:01 +08:00 committed by Hexxa
parent 8d83ce0209
commit 65da92aece
2 changed files with 11 additions and 12 deletions

View file

@ -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<string, string>());
expect(coreState.uploadingsInfo.uploadings).toEqual(List<UploadEntry>([]));

View file

@ -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<string, string>) => {
const shareDir = params.get(shareDirQuery);
this.props.ui.control.controls = this.props.ui.control.controls.set(
sharingCtrl,
shareDir !== "" ? ctrlOn : ctrlOff
);
};
initAuth = async (): Promise<string> => {
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) !== "";