fix(state_mgr): incorrect state init

This commit is contained in:
hexxa 2021-08-19 21:55:13 +08:00 committed by Hexxa
parent cf3332a22f
commit 101d47b2f7
5 changed files with 40 additions and 35 deletions

View file

@ -478,9 +478,13 @@ export class Browser extends React.Component<Props, State, {}> {
});
const sharingList = this.props.sharings.map((dirPath: string) => {
return (
<div key={dirPath} className="flex-list-container">
<span className="flex-list-item-l">{dirPath}</span>
<span className="flex-list-item-r">
<span className="flex-list-item-l">
<span className="dot yellow3-bg"></span>
<span className="bold">{dirPath}</span>
</span>
<span className="flex-list-item-r padding-r-m">
<button
onClick={() => {
this.deleteSharing(dirPath);
@ -490,11 +494,10 @@ export class Browser extends React.Component<Props, State, {}> {
Delete
</button>
</span>
</div>;
</div>
);
});
console.log("browser", this.props.sharings, this.props.isSharing);
return (
<div>
<div id="op-bar" className="op-bar">
@ -535,7 +538,7 @@ export class Browser extends React.Component<Props, State, {}> {
<div className="flex-list-container bold">
<span className="flex-list-item-l">
<span className="dot black-bg"></span>
<span>Uploading Files</span>
<span>Sharing Folders</span>
</span>
<span className="flex-list-item-r padding-r-m"></span>
</div>

View file

@ -179,7 +179,16 @@ export class Updater {
...prevState,
panel: {
...prevState.panel,
browser: { ...this.props }, // TODO: use spread
browser: {
dirPath: this.props.dirPath,
isSharing: this.props.isSharing,
items: this.props.items,
uploadings: this.props.uploadings,
sharings: this.props.sharings,
uploadFiles: this.props.uploadFiles,
uploadValue: this.props.uploadValue,
isVertical: this.props.isVertical,
},
},
};
};

View file

@ -43,7 +43,6 @@ export class RootFrame extends React.Component<Props, State, {}> {
render() {
const update = this.props.update;
console.log("rootframe", this.props.browser.isSharing);
return (
<div className="theme-white desktop">

View file

@ -38,44 +38,38 @@ export class StateMgr extends React.Component<Props, State, {}> {
return BrowserUpdater().refreshUploadings();
})
.then((_: boolean) => {
BrowserUpdater().initUploads();
return BrowserUpdater().initUploads();
})
.then(() => {
BrowserUpdater().setSharing(BrowserUpdater().props.dirPath.join("/"));
return BrowserUpdater().setSharing(
BrowserUpdater().props.dirPath.join("/")
);
})
.then(() => {
BrowserUpdater().listSharings();
return BrowserUpdater().listSharings();
})
.then(() => {
this.update(BrowserUpdater().setBrowser);
console.log("0", this.state, BrowserUpdater().props);
})
.then(() => {
PanesUpdater.self();
console.log("1", this.state);
return PanesUpdater.self();
})
.then(() => {
PanesUpdater.listRoles();
console.log("2", this.state);
return PanesUpdater.listRoles();
})
.then(() => {
PanesUpdater.listUsers();
console.log("3", this.state);
return PanesUpdater.listUsers();
})
.then(() => {
this.update(PanesUpdater.updateState);
console.log("final", this.state);
});
};
update = (apply: (prevState: ICoreState) => ICoreState): void => {
this.setState(apply(this.state));
console.log("core", this.state);
};
render() {
console.log("state_mgr", this.state.panel.browser.isSharing);
return (
<RootFrame
authPane={this.state.panel.authPane}

View file

@ -20,7 +20,7 @@ const (
RoleListNs = "roleList"
InitTimeKey = "initTime"
defaultSpaceLimit = 1024 // 1GB
defaultSpaceLimit = 1024 * 1024 * 1024 // 1GB
defaultUploadSpeedLimit = 50 * 1024 * 1024 // 50MB
defaultDownloadSpeedLimit = 50 * 1024 * 1024 // 50MB
)