Skip to content

Commit

Permalink
add reset all layoutmap to default function
Browse files Browse the repository at this point in the history
  • Loading branch information
loveluthien committed Nov 15, 2024
1 parent a57d62c commit 6d1f41f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/stores/LayoutStore/LayoutStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,32 @@ export class LayoutStore {
console.log(err);
}
}

@flow.bound *setAllLayoutMapDefault() {
try {
const appStore = AppStore.Instance;
let successArr: any[] = [];

for (let i = 0; i < this.existLayoutMap.layoutMap.length; i++) {
const success = yield appStore.apiService.setLayoutMap(
LAYOUT_MAP_NAME,
{
layoutMap: [{ctype: this.existLayoutMap.layoutMap[i].ctype, layoutName: PreferenceStore.Instance.layout}]
},
i
);
successArr.push(success);
}

const success = successArr.every((s: boolean) => s === true);
if (success) {
yield this.fetchLayoutMap();
this.matchLayoutMap();
} else {
AlertStore.Instance.showAlert("Reset all LayoutMap to default failed!");
}
} catch (err) {
console.log(err);
}
}
}

0 comments on commit 6d1f41f

Please sign in to comment.