Skip to content

Commit 329d6fd

Browse files
Fixes #559 - Add Autostaple Algorithm (#1062)
* Fixes #559 - Add Autostaple
1 parent b79bdba commit 329d6fd

File tree

3 files changed

+694
-9
lines changed

3 files changed

+694
-9
lines changed

lib/src/middleware/autostaple_and_autobreak.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@ autostaple_and_autobreak_middleware(Store<AppState> store, dynamic action, NextD
2222
}
2323

2424
_autostaple(Store<AppState> store) async {
25-
print("autostaple, sending design to server ${constants.autostaple_url}");
26-
var response = await http.post(
27-
Uri.parse(constants.autostaple_url),
28-
body: json_encode(store.state.design),
29-
headers: {"Content-Type": "application/json"},
30-
);
31-
print("response: ${response.body}");
32-
33-
_handle_response(store, response, "autostaple");
25+
// ! - Commented out code was prior implementation of autostaple on a remote server
26+
// print("autostaple, sending design to server ${constants.autostaple_url}");
27+
// var response = await http.post(
28+
// Uri.parse(constants.autostaple_url),
29+
// body: json_encode(store.state.design),
30+
// headers: {"Content-Type": "application/json"},
31+
// );
32+
// print("response: ${response.body}");
33+
//
34+
// _handle_response(store, response, "autostaple");
35+
try {
36+
Design design_new = store.state.design.autostaple();
37+
store.dispatch(actions.NewDesignSet(design_new, "autostaple"));
38+
} catch (e) {
39+
window.alert('Error during autostaple: ${e}');
40+
}
3441
}
3542

3643
_autobreak(Store<AppState> store, actions.Autobreak action) async {

0 commit comments

Comments
 (0)