mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 09:21:42 +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:
|
:: 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
|
/+ *link, default-agent, verb, dbug
|
||||||
::
|
::
|
||||||
@ -151,6 +154,9 @@
|
|||||||
::
|
::
|
||||||
[%x %seen @ ^]
|
[%x %seen @ ^]
|
||||||
``noun+!>((is-seen t.t.path))
|
``noun+!>((is-seen t.t.path))
|
||||||
|
::
|
||||||
|
[%x %unseen *]
|
||||||
|
``noun+!>((get-unseen t.t.path))
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ on-watch
|
++ on-watch
|
||||||
@ -372,6 +378,17 @@
|
|||||||
%+ ~(put by *(map ^path submissions)) path
|
%+ ~(put by *(map ^path submissions)) path
|
||||||
submissions:(~(gut by by-group) path *links)
|
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
|
++ is-seen
|
||||||
|= =path
|
|= =path
|
||||||
^- ?
|
^- ?
|
||||||
|
@ -248,6 +248,16 @@
|
|||||||
|= [=^path =submissions]
|
|= [=^path =submissions]
|
||||||
^- [@t json]
|
^- [@t json]
|
||||||
:- (spat path)
|
:- (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
|
%^ page-to-json p
|
||||||
%+ get-paginated `p
|
%+ get-paginated `p
|
||||||
submissions
|
submissions
|
||||||
|
@ -18,6 +18,9 @@ export class ChannelsSidebar extends Component {
|
|||||||
let name = "Private"
|
let name = "Private"
|
||||||
let selected = (props.selected === path);
|
let selected = (props.selected === path);
|
||||||
let linkCount = !!props.links[path] ? props.links[path].totalItems : 0;
|
let linkCount = !!props.links[path] ? props.links[path].totalItems : 0;
|
||||||
|
const unseenCount = !!props.links[path]
|
||||||
|
? props.links[path].unseenCount
|
||||||
|
: linkCount
|
||||||
return (
|
return (
|
||||||
<ChannelsItem
|
<ChannelsItem
|
||||||
key={path}
|
key={path}
|
||||||
@ -25,6 +28,7 @@ export class ChannelsSidebar extends Component {
|
|||||||
members={props.paths[path]}
|
members={props.paths[path]}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
linkCount={linkCount}
|
linkCount={linkCount}
|
||||||
|
unseenCount={unseenCount}
|
||||||
name={name}/>
|
name={name}/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -11,6 +11,9 @@ export class ChannelsItem extends Component {
|
|||||||
: "b--transparent";
|
: "b--transparent";
|
||||||
|
|
||||||
let memberCount = Object.keys(props.members).length;
|
let memberCount = Object.keys(props.members).length;
|
||||||
|
const unseenCount = props.unseenCount > 0
|
||||||
|
? <span className="green2">{" " + props.unseenCount + " unread"}</span>
|
||||||
|
: null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link to={"/~link" + props.link}>
|
<Link to={"/~link" + props.link}>
|
||||||
@ -21,6 +24,7 @@ export class ChannelsItem extends Component {
|
|||||||
</p>
|
</p>
|
||||||
<p className="f9 pb1">
|
<p className="f9 pb1">
|
||||||
{props.linkCount + " link" + ((props.linkCount === 1) ? "" : "s")}
|
{props.linkCount + " link" + ((props.linkCount === 1) ? "" : "s")}
|
||||||
|
{unseenCount}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -41,6 +41,7 @@ export class LinkUpdateReducer {
|
|||||||
state.links[path].local[page] = false;
|
state.links[path].local[page] = false;
|
||||||
state.links[path].totalPages = here.totalPages;
|
state.links[path].totalPages = here.totalPages;
|
||||||
state.links[path].totalItems = here.totalItems;
|
state.links[path].totalItems = here.totalItems;
|
||||||
|
state.links[path].unseenCount = here.unseenCount;
|
||||||
|
|
||||||
// write seen status to a separate structure,
|
// write seen status to a separate structure,
|
||||||
// for easier modification later.
|
// for easier modification later.
|
||||||
@ -74,6 +75,8 @@ export class LinkUpdateReducer {
|
|||||||
state.links[path] = this._addNewItems(
|
state.links[path] = this._addNewItems(
|
||||||
data.pages, state.links[path]
|
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 => {
|
data.urls.map(url => {
|
||||||
seen[url] = true;
|
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