pull/645/head
Tienson Qin 2020-05-27 21:39:19 +08:00
parent 6d3483b230
commit 5531140ee1
2 changed files with 19 additions and 8 deletions

View File

@ -460,16 +460,20 @@
(string/trim (state/get-edit-content input-id))))
(defn alter-file
[repo-url path content {:keys [reset?]
[repo path content {:keys [reset?]
:or {reset? true}}]
(if reset?
(db/reset-file! repo-url path content)
(db/set-file-content! repo-url path content))
(db/reset-file! repo path content)
(db/set-file-content! repo path content))
(util/p-handle
(fs/write-file (util/get-repo-dir repo-url) path content)
(fs/write-file (util/get-repo-dir repo) path content)
(fn [_]
(git-add repo-url path)
(re-render-root!))))
(git-add repo path)
(re-render-root!)
(history/add-history!
[:git/repo repo]
{:db (d/db (db/get-conn repo false))
:files-db (d/db (db/get-files-conn repo))}))))
(defn transact-react-and-alter-file!
[repo tx transact-option file-path new-content]

View File

@ -62,13 +62,19 @@
[k value]
(when (and k value)
(let [id (d/squuid)
_ (reset! current-id id)
value (assoc value :id id)]
(prn "History id: " id)
(swap! history update k
(fn [col]
(let [col (if @current-id
(do
(prn "drop tail id: " @current-id)
(drop-tail col #(= @current-id (:id %))))
col)])
(-> col
(conj value)
(trim-head history-limit)))))))
(trim-head history-limit))))
(reset! current-id id))))
(defn traverse!
[k undo?]
@ -80,6 +86,7 @@
(let [{:keys [id db files-db]} item]
(when (and (vector? k)
(= (first k) :git/repo))
(println (if undo? "Undo: " "Redo: ") id)
(let [repo (last k)]
(db/reset-conn! (db/get-conn repo false) db)
(db/reset-conn! (db/get-files-conn repo) files-db)