diff --git a/pkg/arvo/app/link-store.hoon b/pkg/arvo/app/link-store.hoon index 44acf5f2af..34dc93e2ea 100644 --- a/pkg/arvo/app/link-store.hoon +++ b/pkg/arvo/app/link-store.hoon @@ -40,8 +40,12 @@ :: :: scry-only paths: :: +:: +:: (map path (set url)) +:: /unseen the ones we haven't seen yet +:: :: (set url) -:: /seen//some-path the ones we've seen here +:: /unseen/some-path the ones we haven't seen here yet :: :: ? :: /seen/wood-url/some-path have we seen this here @@ -153,10 +157,13 @@ ``noun+!>((get-discussions:do t.t.path)) :: [%x %seen @ ^] - ``noun+!>((is-seen t.t.path)) + ``noun+!>((is-seen:do t.t.path)) :: - [%x %unseen *] - ``noun+!>((get-unseen t.t.path)) + [%x %unseen ~] + ``noun+!>(get-all-unseen:do) + :: + [%x %unseen ^] + ``noun+!>((get-unseen:do t.t.path)) == :: ++ on-watch @@ -235,12 +242,16 @@ =. by-group (~(put by by-group) path links) :: do generic submission logic :: - =^ cards state + =^ submission-cards state (hear-submission path [our.bowl page]) + :: mark page as seen (because we submitted it ourselves) + :: + =^ seen-cards state + (seen-submission path `url) :: send updates to subscribers :: :_ state - :_ cards + :_ (weld submission-cards seen-cards) :+ %give %fact :+ :~ /local-pages [%local-pages path] @@ -378,6 +389,12 @@ %+ ~(put by *(map ^path submissions)) path submissions:(~(gut by by-group) path *links) :: +++ get-all-unseen + ^- (jug path url) + %- ~(rut by by-group) + |= [=path *] + (get-unseen path) +:: ++ get-unseen |= =path ^- (set url) diff --git a/pkg/arvo/app/link-view.hoon b/pkg/arvo/app/link-view.hoon index eee487ea38..87814a424b 100644 --- a/pkg/arvo/app/link-view.hoon +++ b/pkg/arvo/app/link-view.hoon @@ -40,7 +40,7 @@ [%pass /discussions %agent [our.bowl %link-store] %watch /discussions] [%pass /seen %agent [our.bowl %link-store] %watch /seen] :: - =+ [%link-server-hook /tile '/~link/js/tile.js'] + =+ [dap.bowl /tile '/~link/js/tile.js'] [%pass /launch %agent [our.bowl %launch] %poke %launch-action !>(-)] == :: @@ -74,13 +74,13 @@ ?=([%json %seen ~] path) == [~ this] + ?: ?=([%tile ~] path) + :_ this + ~[give-tile-data:do] ?. ?=([%json @ @ *] path) (on-watch:def path) =/ p=@ud (slav %ud i.t.path) ?+ t.t.path (on-watch:def path) - [%tile ~] - [~ this] - :: [%submissions ~] :_ this (give-initial-submissions:do p ~) @@ -111,7 +111,12 @@ =* vase q.cage.sign ?+ mark (on-agent:def wire sign) %link-initial [~ this] - %link-update [~[(send-update:do !<(update vase))] this] + :: + %link-update + :_ this + :- (send-update:do !<(update vase)) + ?: =(/discussions wire) ~ + ~[give-tile-data:do] == == :: @@ -216,6 +221,23 @@ |= =action ^- card [%pass /action %agent [our.bowl %link-store] %poke %link-action !>(action)] +:: +give-tile-data: total unread count as json object +:: +::NOTE the full recalc of totals here probably isn't the end of the world. +:: but in case it is, well, here it is. +:: +++ give-tile-data + ^- card + =; =json + [%give %fact ~[/tile] %json !>(json)] + %+ frond:enjs:format 'unseen' + %- numb:enjs:format + %- %~ rep in + (scry-for (jug path url) /unseen) + |= [[=path unseen=(set url)] total=@ud] + %+ add total + ~(wyt in unseen) +:: :: +give-initial-submissions: page of submissions on path :: :: for the / path, give page for every path diff --git a/pkg/interface/link/tile/tile.js b/pkg/interface/link/tile/tile.js index 5a486b6113..141b78b29b 100644 --- a/pkg/interface/link/tile/tile.js +++ b/pkg/interface/link/tile/tile.js @@ -6,7 +6,20 @@ import _ from 'lodash'; export default class LinkTile extends Component { render() { - const { props } = this; + const unseenCount = this.props.data.unseen || 0; + + let displayUnseen = unseenCount <= 0 + ? null + :

+ {unseenCount > 99 ? "99+" : unseenCount} +

; return (
@@ -23,6 +36,7 @@ export default class LinkTile extends Component { width={48} height={48} /> + {displayUnseen}
); @@ -30,4 +44,4 @@ export default class LinkTile extends Component { } -window['link-server-hookTile'] = LinkTile; +window['link-viewTile'] = LinkTile;