aboutsummaryrefslogtreecommitdiff
path: root/src/refreshToDos.js
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-29 18:28:55 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-29 18:28:55 -0600
commitdaee56ba5509a4576fa066adfcc0d1bc05f98802 (patch)
tree0c0fd7ebb94ca5c4ad82dbea16ba2b58e91900a2 /src/refreshToDos.js
parent4285674ab37c74a24b265ace4d15d4848457d375 (diff)
downloadToDo-App-FE-daee56ba5509a4576fa066adfcc0d1bc05f98802.tar.gz
ToDo-App-FE-daee56ba5509a4576fa066adfcc0d1bc05f98802.zip
Adding new to dos is now synchronized with database.
Changed the `refreshToDos` to also refresh the last index used.
Diffstat (limited to '')
-rw-r--r--src/refreshToDos.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/refreshToDos.js b/src/refreshToDos.js
index c599606..a6b1368 100644
--- a/src/refreshToDos.js
+++ b/src/refreshToDos.js
@@ -1,9 +1,15 @@
-import { set_todo, empty_todos, change_page } from "./features/todo/reducer";
+import {
+ set_last_id,
+ set_todo,
+ empty_todos,
+ change_page,
+} from "./features/todo/reducer";
import {
set_fil_sort_function,
get_todos_page_function,
get_nu_pages_function,
+ get_last_id_function,
} from "./api/axios_methods";
export function refresh_todos(my_filters, my_sorters, my_curr_page, dispatch) {
@@ -64,4 +70,14 @@ export function refresh_todos(my_filters, my_sorters, my_curr_page, dispatch) {
}
get_todos_api(handle_new_todos_page, { page: my_curr_page });
+
+ // Finally, retrieve the last index used for a to do.
+ const last_id_api = get_last_id_function();
+ last_id_api((response) => {
+ dispatch(
+ set_last_id({
+ id: response,
+ })
+ );
+ });
}