A peer-to-peer stack for code collaboration
Remove seen/unseen functionality from diff app (#424)
Merle Breitkreuzb64252115f1b
diff --git a/bin/rad-diff b/bin/rad-diffindex 2cd64e2..3bd14b5 100755--- a/bin/rad-diff+++ b/bin/rad-diff@@ -16,7 +16,7 @@(def chain-name (fn [] (get-rsm-of-type! :rad-diff)))(def valid-list-options- ["--new" "--pending" "--retracted" "--accepted" "--rejected" "--fancy"])+ ["--pending" "--retracted" "--accepted" "--rejected" "--fancy"])(def list-opts-help(foldl (fn [a opt] (string-append a " [" opt "]")) "" valid-list-options))@@ -31,11 +31,9 @@rad-diff propose <commit>rad-diff [retract|accept|reject|show] <diff-no>rad-diff comment <diff-no> <comment>- rad-diff donerad-diff helplist - Select from diffs to view or comment on- done - Mark all diffs as 'seen'propose - Create a new diff in $EDITORshow - Show a diffcomment - Shortcut for adding a comment@@ -50,12 +48,6 @@(fn [error](parse-failure error help)))-(def mark-last-seen- (fn []- (write-file-key! ".radicle-diffs" :last-mark-done (now!))))--(init-file-dict! ".radicle-diffs")-(def verify-diff-number(fn [diff-no chain-ref](match (lookup-default diff-no #f (list-diffs chain-ref))@@ -205,43 +197,31 @@(def chain-ref (chain/make-chain-ref! chain))(def mk-key- (fn [v]- (match v- (/as 'a {:activity :new-diff- :diff 'diff})- [(string-append "[new/changed] " (pretty-headline diff)) a]- (/as 'a {:activity :new-comments- :diff 'diff})- [(string-append "[new comments] " (pretty-headline diff)) a]- (/as 'i {:diff 'diff})- [(pretty-headline diff) i])))+ (fn [diff] [(pretty-headline diff) diff]))(def filt- (match (filter (fn [opt] (not (elem? opt [:new :fancy]))) options)+ (match (filter (fn [opt] (not (eq? opt :fancy))) options)[] (fn [x] #t)- _ (fn [x] (elem? (lookup :state (lookup :diff x)) options))))+ _ (fn [x] (elem? (lookup :state x) options))))(def items(map mk-key(filter filt- (match [(elem? :new options) (read-file-key! ".radicle-diffs" :last-mark-done)]- [#t [:just 't]] (recent-activity chain-ref t)- _ (map (fn [i] {:diff i})- (reverse (values (list-diffs chain-ref))))))))+ (reverse (values (list-diffs chain-ref))))))(def items-dict (dict-from-seq items))(if (empty-seq? items)- (put-str! "No recent items!")+ (put-str! "No diffs!")(if (elem? :fancy options)(match (fzf-select-with-preview!(map first items)- (fn [s] (pretty-diff (lookup :diff (lookup s items-dict)))))+ (fn [s] (pretty-diff (lookup s items-dict))))(/just 's)(do (def selected (lookup s items-dict))- (def diff-number (match selected {:diff {:number 'n}} n))+ (def diff-number (match selected {:number 'n} n))(def pretty-item(add-comment-md- (pretty-diff (lookup :diff selected))))+ (pretty-diff selected)))(def edited-item (edit-in-editor! pretty-item))(def added-comment(string/unlines@@ -328,7 +308,6 @@(/cmd-1 "reject" 'diff-no help) (edit-diff-state! (chain-name) (read diff-no) :rejected)["comment" 'diff-no 'comment] (create-comment! (chain-name) (read diff-no) comment)(/cmd-0 "create-chain" help) (new-diff-chain! (chain-name))- (/cmd-0 "done" help) (mark-last-seen)["help"] (put-str! help)["-h"] (put-str! help)["--help"] (put-str! help)diff --git a/rad/monadic/diff.rad b/rad/monadic/diff.radindex eb3f3eb..8b30f9d 100644--- a/rad/monadic/diff.rad+++ b/rad/monadic/diff.rad@@ -73,45 +73,10 @@(fn [chain](lookup :result (chain/eval-in-chain '(list-diffs) (read-ref chain)))))-(def recent-activity- "Returns the activity on the chain since a timestamp."- (fn [chain from]- (def mod-at- (fn [x]- (unix-epoch- (lookup :modified-at x))))- (def u (unix-epoch from))- (def since- (fn [xs]- (filter (fn [x] (< u (mod-at x))) xs)))- (def most-recent-first- (fn [xs]- (sort-by (fn [x] (- 0 (mod-at x)))- xs)))- (def all-diffs (values (list-diffs chain)))- (def is (map (fn [i]- {:activity :new-diff- :modified-at (lookup :modified-at i)- :diff i})- (since all-diffs)))- (def cs- (cat-maybes- (map (fn [i]- (def xs (most-recent-first (since (lookup :comments i))))- (if (eq? xs [])- :nothing- [:just- {:activity :new-comments- :modified-at (lookup :modified-at (first xs))- :diff i}]))- all-diffs)))- (most-recent-first (<> is cs))))-(:test"The monadic diffs chain works."[:setup(do (chain/install-remote-chain-fake)- (install-fake-clock)(use-fake-keys!)(def chain-name "http://foo")(def chain (ref (chain/new-chain chain-name)))@@ -121,19 +86,12 @@(simple-add-comment! chain 0 "comment0" "name0")(simple-add-comment! chain 1 "comment1" "name1")(simple-edit-diff! chain 0 {:state :accepted})- (def t (now!))- (simple-create-diff! chain {:title "new" :description "new" :patch "new"})- (simple-create-diff! chain {:title "newer" :description "newer" :patch "newer"})- (simple-add-comment! chain 0 "new" "name0")(chain/update-chain-ref! chain)- (def diffs (list-diffs chain))- (def new (recent-activity chain t)))]- [ (length (seq diffs)) ==> 4 ]+ (def diffs (list-diffs chain)))]+ [ (length (seq diffs)) ==> 2 ][ (view (.. (@ 0) (@ :title)) diffs) ==> "title0" ][ (view (.. (@ 1) (@ :title)) diffs) ==> "title1" ]+ [ (view (... [(@ 0) (@ :comments) (@nth 0) (@ :body)]) diffs) ==> "comment0" ][ (view (... [(@ 1) (@ :comments) (@nth 0) (@ :body)]) diffs) ==> "comment1" ][ (view (.. (@ 0) (@ :state)) diffs) ==> :accepted ]- [ (length new) ==> 3 ]- [ (view (.. (@nth 0) (@ :activity)) new) ==> :new-comments ]- [ (view (... [(@nth 1) (@ :diff) (@ :title)]) new) ==> "newer" ])