Skip to content

Commit

Permalink
fix: fix render sketch (#342)
Browse files Browse the repository at this point in the history
* fix: fix render sketch

* mod: code review
  • Loading branch information
hetao92 committed Nov 2, 2022
1 parent c29f1ce commit 8d64659
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 0 additions & 7 deletions app/pages/SketchModeling/SketchConfigHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ const SketchConfigHeader: React.FC = () => {
const code = await updateSketch({ name: value });
if (code === 0) {
message.success(intl.get('sketch.updateNameSuccess'));
await getSketchList();
sketchModel.update({
currentSketch: {
...currentSketch,
name: value
}
});
}
};
return (
Expand Down
1 change: 1 addition & 0 deletions app/pages/SketchModeling/SketchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const SketchList: React.FC = () => {
<Input
allowClear
placeholder={intl.get('sketch.search')}
defaultValue={sketchList.filter.keyword}
className={styles.searchInput}
onChange={debounceChange}
suffix={<Icon type="icon-nav-filter" />}
Expand Down
17 changes: 14 additions & 3 deletions app/stores/sketchModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeAutoObservable, observable, action } from 'mobx';
import { makeAutoObservable, observable, action, runInAction } from 'mobx';
import { message } from 'antd';
import intl from 'react-intl-universal';
import { getRootStore } from '@app/stores';
Expand Down Expand Up @@ -153,13 +153,24 @@ export class SketchStore {

updateSketch = async (params: { name?: string; schema?: string; snapshot?: string }) => {
const { id, name, schema, snapshot } = this.currentSketch;
const { code } = await service.updateSketch({
const _params = {
id,
name,
schema,
snapshot,
...params,
});
};
const { code } = await service.updateSketch(_params);
if(code === 0) {
runInAction(() => {
const item = this.sketchList.items.find(item => item.id === id);
item.name = _params.name;
this.currentSketch = {
...this.currentSketch,
..._params
};
});
}
return code;
};

Expand Down

0 comments on commit 8d64659

Please sign in to comment.