From 1f98b168ba95dc48080b35f70f87ec565d4fd7ec Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 28 Jul 2023 13:18:19 +0200 Subject: [PATCH] :bug: Set correct modification date on projects on file move operation --- backend/src/app/rpc/commands/management.clj | 15 ++++++++++++++- frontend/src/app/main/data/dashboard.cljs | 11 ++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend/src/app/rpc/commands/management.clj b/backend/src/app/rpc/commands/management.clj index dff27e497d..147717aac0 100644 --- a/backend/src/app/rpc/commands/management.clj +++ b/backend/src/app/rpc/commands/management.clj @@ -28,7 +28,8 @@ [app.util.services :as sv] [app.util.time :as dt] [clojure.spec.alpha :as s] - [clojure.walk :as walk])) + [clojure.walk :as walk] + [promesa.exec :as px])) ;; --- COMMAND: Duplicate File @@ -322,6 +323,18 @@ ;; delete possible broken relations on moved files (db/exec-one! conn [sql:delete-broken-relations pids]) + ;; Update the modification date of the all affected projects + ;; ensuring that the destination project is the most recent one. + (doseq [project-id (into (list project-id) source)] + + ;; NOTE: as this is executed on virtual thread, sleeping does + ;; not causes major issues, and allows an easy way to set a + ;; trully different modification date to each file. + (px/sleep 10) + (db/update! conn :project + {:modified-at (dt/now)} + {:id project-id})) + nil)) (s/def ::ids (s/every ::us/uuid :kind set?)) diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index d31c6929d9..725e014a41 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -10,7 +10,6 @@ [app.common.data.macros :as dm] [app.common.pages :as cp] [app.common.schema :as sm] - [app.common.time :as dt] [app.common.uri :as u] [app.common.uuid :as uuid] [app.config :as cf] @@ -23,6 +22,7 @@ [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] + [app.util.time :as dt] [app.util.timers :as tm] [app.util.webapi :as wapi] [beicon.core :as rx] @@ -863,6 +863,7 @@ [{:keys [ids project-id] :as params}] (dm/assert! (sm/set-of-uuid? ids)) (dm/assert! (uuid? project-id)) + (ptk/reify ::move-files IDeref (-deref [_] @@ -872,13 +873,13 @@ ptk/UpdateEvent (update [_ state] (let [origin-project (get-in state [:dashboard-files (first ids) :project-id]) - update-project (fn [project] + update-project (fn [project delta] (-> project (update :count #(+ % (count ids))) - (assoc :modified-at (dt/now))))] + (assoc :modified-at (dt/plus (dt/now) {:milliseconds delta}))))] (-> state - (d/update-in-when [:dashboard-projects origin-project] update-project) - (d/update-in-when [:dashboard-projects project-id] update-project)))) + (d/update-in-when [:dashboard-projects origin-project] update-project 0) + (d/update-in-when [:dashboard-projects project-id] update-project 10)))) ptk/WatchEvent (watch [_ _ _]