mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-27 10:52:41 +03:00
settings: adds loading states
This commit is contained in:
parent
c21dca1884
commit
ad5fec1201
@ -71,17 +71,16 @@ export const add = (user, data) => {
|
||||
return { ...user.data, library };
|
||||
};
|
||||
|
||||
// NOTE(jim): Not sure if we're going to use this?
|
||||
export const removeById = (user, dataId) => {
|
||||
const { library } = user.data;
|
||||
|
||||
// TODO(jim): Since we don't support bucket organization... yet.
|
||||
// Add just pushes to the first set. But we can change this easily later.
|
||||
// TODO(jim): Totally purges the ID.
|
||||
for (let i = 0; i < library.length; i++) {
|
||||
for (let j = 0; j < library[i].children.length; j++) {
|
||||
library[i].children[j] = library[i].children[j].filter(
|
||||
(e) => e.id !== dataId
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ export default class SceneSettings extends React.Component {
|
||||
_deferredSave = null;
|
||||
|
||||
_handleSave = async () => {
|
||||
this.setState({ loading: true });
|
||||
|
||||
await Actions.updateViewer({
|
||||
type: "SET_DEFAULT_STORAGE_CONFIG",
|
||||
data: {
|
||||
@ -73,6 +75,10 @@ export default class SceneSettings extends React.Component {
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await this.props.onRehydrate();
|
||||
|
||||
this.setState({ loading: false });
|
||||
};
|
||||
|
||||
_handleChange = (e) => {
|
||||
@ -103,7 +109,16 @@ export default class SceneSettings extends React.Component {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div css={STYLES_GROUP} style={{ marginTop: 32 }}>
|
||||
<div style={{ marginTop: 24 }}>
|
||||
<System.ButtonPrimary
|
||||
loading={this.state.loading}
|
||||
onClick={this._handleSave}
|
||||
>
|
||||
Save
|
||||
</System.ButtonPrimary>
|
||||
</div>
|
||||
|
||||
<div css={STYLES_GROUP} style={{ marginTop: 48 }}>
|
||||
<div css={STYLES_LEFT}>
|
||||
<System.DescriptionGroup
|
||||
label="Enable cold storage"
|
||||
@ -187,8 +202,11 @@ export default class SceneSettings extends React.Component {
|
||||
placeholder="Type in amount of Filecoin"
|
||||
onChange={this._handleChange}
|
||||
/>
|
||||
<div style={{ marginTop: 32 }}>
|
||||
<System.ButtonPrimary onClick={this._handleSave}>
|
||||
<div style={{ marginTop: 24 }}>
|
||||
<System.ButtonPrimary
|
||||
loading={this.state.loading}
|
||||
onClick={this._handleSave}
|
||||
>
|
||||
Save
|
||||
</System.ButtonPrimary>
|
||||
</div>
|
||||
@ -234,8 +252,11 @@ export default class SceneSettings extends React.Component {
|
||||
onChange={this._handleChange}
|
||||
/>
|
||||
|
||||
<div style={{ marginTop: 32 }}>
|
||||
<System.ButtonPrimary onClick={this._handleSave}>
|
||||
<div style={{ marginTop: 24 }}>
|
||||
<System.ButtonPrimary
|
||||
loading={this.state.loading}
|
||||
onClick={this._handleSave}
|
||||
>
|
||||
Save
|
||||
</System.ButtonPrimary>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user