From 4a7fcc2d84d224015a75fb67643c4f7e0f786774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Tue, 20 Aug 2024 16:03:04 +0200 Subject: [PATCH] Chekc request diff --- bin/main.ml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/main.ml b/bin/main.ml index 2b53f83..218e2af 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -107,6 +107,7 @@ let app = (filters, f_libraries.value) in let main_view = + let previous_value = ref None in let request = Ui_utils.map3 f_value f_search.value f_sort_order ~f:(fun l t (s, o) -> let filters = Option.map (fun s -> [ Db.View.Search s ]) t in @@ -120,9 +121,17 @@ let app = let open Fut.Result_syntax in let sort = Db.View.Sort.of_string s in let open Fut.Result_syntax in - Console.debug [ "Request changed" ]; - Db.View.( - req Audio ~src_views:(Only (Lwd_seq.to_list l)) ~sort ?filters ())) + let new_view = + Db.View.( + req Audio ~src_views:(Only (Lwd_seq.to_list l)) ~sort ?filters ()) + in + Option.map_or ~default:new_view + (fun old -> + if Equal.poly old new_view then old + else ( + previous_value := Some new_view; + new_view)) + !previous_value) in let item_count = Lwd.map request ~f:(fun req -> Worker_client.get_view_item_count req)