settings: adds loading states

This commit is contained in:
@wwwjim 2020-07-23 20:15:32 -07:00
parent c21dca1884
commit ad5fec1201
2 changed files with 28 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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>