From daee56ba5509a4576fa066adfcc0d1bc05f98802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Mon, 29 May 2023 18:28:55 -0600 Subject: Adding new to dos is now synchronized with database. Changed the `refreshToDos` to also refresh the last index used. --- src/refreshToDos.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/refreshToDos.js') 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, + }) + ); + }); } -- cgit v1.2.3