mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 01:01:37 +03:00
Merge pull request #2259 from urbit/m/link-unreader
link: unread counters in sidebar
This commit is contained in:
commit
5eab689d0a
@ -40,8 +40,11 @@
|
||||
::
|
||||
:: scry-only paths:
|
||||
::
|
||||
:: (set url)
|
||||
:: /seen//some-path the ones we've seen here
|
||||
::
|
||||
:: ?
|
||||
:: /seen/wood-url/some-path have we seen this here (scry only)
|
||||
:: /seen/wood-url/some-path have we seen this here
|
||||
::
|
||||
/+ *link, default-agent, verb, dbug
|
||||
::
|
||||
@ -151,6 +154,9 @@
|
||||
::
|
||||
[%x %seen @ ^]
|
||||
``noun+!>((is-seen t.t.path))
|
||||
::
|
||||
[%x %unseen *]
|
||||
``noun+!>((get-unseen t.t.path))
|
||||
==
|
||||
::
|
||||
++ on-watch
|
||||
@ -372,6 +378,17 @@
|
||||
%+ ~(put by *(map ^path submissions)) path
|
||||
submissions:(~(gut by by-group) path *links)
|
||||
::
|
||||
++ get-unseen
|
||||
|= =path
|
||||
^- (set url)
|
||||
=/ =links
|
||||
(~(gut by by-group) path *links)
|
||||
%- ~(gas in *(set url))
|
||||
%+ murn submissions.links
|
||||
|= submission
|
||||
?: (~(has in seen.links) url) ~
|
||||
(some url)
|
||||
::
|
||||
++ is-seen
|
||||
|= =path
|
||||
^- ?
|
||||
|
@ -248,6 +248,16 @@
|
||||
|= [=^path =submissions]
|
||||
^- [@t json]
|
||||
:- (spat path)
|
||||
=; =json
|
||||
:: add unseen count
|
||||
::
|
||||
?> ?=(%o -.json)
|
||||
:- %o
|
||||
%+ ~(put by p.json) 'unseenCount'
|
||||
%- numb:enjs:format
|
||||
%~ wyt in
|
||||
%+ scry-for (set url)
|
||||
[%unseen path]
|
||||
%^ page-to-json p
|
||||
%+ get-paginated `p
|
||||
submissions
|
||||
|
@ -18,6 +18,9 @@ export class ChannelsSidebar extends Component {
|
||||
let name = "Private"
|
||||
let selected = (props.selected === path);
|
||||
let linkCount = !!props.links[path] ? props.links[path].totalItems : 0;
|
||||
const unseenCount = !!props.links[path]
|
||||
? props.links[path].unseenCount
|
||||
: linkCount
|
||||
return (
|
||||
<ChannelsItem
|
||||
key={path}
|
||||
@ -25,6 +28,7 @@ export class ChannelsSidebar extends Component {
|
||||
members={props.paths[path]}
|
||||
selected={selected}
|
||||
linkCount={linkCount}
|
||||
unseenCount={unseenCount}
|
||||
name={name}/>
|
||||
)
|
||||
})
|
||||
|
@ -11,6 +11,9 @@ export class ChannelsItem extends Component {
|
||||
: "b--transparent";
|
||||
|
||||
let memberCount = Object.keys(props.members).length;
|
||||
const unseenCount = props.unseenCount > 0
|
||||
? <span className="green2">{" " + props.unseenCount + " unread"}</span>
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Link to={"/~link" + props.link}>
|
||||
@ -21,6 +24,7 @@ export class ChannelsItem extends Component {
|
||||
</p>
|
||||
<p className="f9 pb1">
|
||||
{props.linkCount + " link" + ((props.linkCount === 1) ? "" : "s")}
|
||||
{unseenCount}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
|
@ -41,6 +41,7 @@ export class LinkUpdateReducer {
|
||||
state.links[path].local[page] = false;
|
||||
state.links[path].totalPages = here.totalPages;
|
||||
state.links[path].totalItems = here.totalItems;
|
||||
state.links[path].unseenCount = here.unseenCount;
|
||||
|
||||
// write seen status to a separate structure,
|
||||
// for easier modification later.
|
||||
@ -74,6 +75,8 @@ export class LinkUpdateReducer {
|
||||
state.links[path] = this._addNewItems(
|
||||
data.pages, state.links[path]
|
||||
);
|
||||
state.links[path].unseenCount =
|
||||
state.links[path].unseenCount + data.pages.length;
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,6 +151,10 @@ export class LinkUpdateReducer {
|
||||
data.urls.map(url => {
|
||||
seen[url] = true;
|
||||
});
|
||||
if (state.links[path]) {
|
||||
state.links[path].unseenCount =
|
||||
state.links[path].unseenCount - data.urls.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user