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

View file

@ -179,7 +179,16 @@ export class Updater {
...prevState, ...prevState,
panel: { panel: {
...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() { render() {
const update = this.props.update; const update = this.props.update;
console.log("rootframe", this.props.browser.isSharing);
return ( return (
<div className="theme-white desktop"> <div className="theme-white desktop">

View file

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

View file

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