Merge pull request #2289 from urbit/m/link-tile

link: properly support the launch tile
This commit is contained in:
Fang 2020-02-14 12:50:26 +01:00 committed by GitHub
commit 5d01b4750b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 13 deletions

View File

@ -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)

View File

@ -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

View File

@ -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
: <p
className="absolute green2"
style={{
bottom: 6,
fontWeight: 400,
fontSize: 12,
lineHeight: "20px"
}}>
{unseenCount > 99 ? "99+" : unseenCount}
</p>;
return (
<div className="w-100 h-100 relative ba b--black bg-white">
@ -23,6 +36,7 @@ export default class LinkTile extends Component {
width={48}
height={48}
/>
{displayUnseen}
</a>
</div>
);
@ -30,4 +44,4 @@ export default class LinkTile extends Component {
}
window['link-server-hookTile'] = LinkTile;
window['link-viewTile'] = LinkTile;