Skip to content

Commit

Permalink
fix: clear store
Browse files Browse the repository at this point in the history
mod: code review

mod: code review
  • Loading branch information
hetao92 committed Dec 22, 2022
1 parent 369d498 commit 2914612
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/pages/Import/FileUpload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const FileUpload = () => {
const [loading, setLoading] = useState(false);
const transformFile = async (_file: StudioFile, fileList: StudioFile[]) => {
const size = fileList.reduce((acc, cur) => acc + cur.size, 0);
if(size > global.gConfig.maxBytes) {
if(global.gConfig?.maxBytes && size > global.gConfig.maxBytes) {
message.error(intl.get('import.fileSizeLimit', { size: getFileSize(global.gConfig.maxBytes) }));
return false;
}
Expand Down
11 changes: 6 additions & 5 deletions app/stores/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ export class ConsoleStore {
}

resetModel = () => {
this.update({
currentGQL: 'SHOW SPACES;',
results: [],
paramsMap: null
});
const shadowStore = new ConsoleStore();
for (const key in shadowStore) {
if (typeof shadowStore[key] !== 'function') {
this[key] = shadowStore[key];
}
}
};

update = (param: Partial<ConsoleStore>) => {
Expand Down
9 changes: 9 additions & 0 deletions app/stores/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export class FilesStore {
Object.keys(payload).forEach(key => Object.prototype.hasOwnProperty.call(this, key) && (this[key] = payload[key]));
};

resetModel = () => {
const shadowStore = new FilesStore();
for (const key in shadowStore) {
if (typeof shadowStore[key] !== 'function') {
this[key] = shadowStore[key];
}
}
};

getFiles = async () => {
const { code, data } = (await service.getFiles()) as any;
if (code === 0 && data) {
Expand Down
9 changes: 8 additions & 1 deletion app/stores/sketchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ export class SketchStore {
sketchList: observable.deep,
});
}

resetModel = () => {
const shadowStore = new SketchStore();
for (const key in shadowStore) {
if (typeof shadowStore[key] !== 'function') {
this[key] = shadowStore[key];
}
}
};
update = (payload: Record<string, any>) => {
Object.keys(payload).forEach(
(key) => Object.prototype.hasOwnProperty.call(this, key) && (this[key] = payload[key])
Expand Down
4 changes: 2 additions & 2 deletions server/api/studio/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/api/studio/restapi/import.api
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type (

GetManyImportTaskRequest {
Page int `form:"page,default=1"`
PageSize int `form:"pageSize,default=100"`
PageSize int `form:"pageSize,default=999"`
}

GetManyImportTaskData {
Expand Down

0 comments on commit 2914612

Please sign in to comment.