Less obstrusive "New posts"

This commit is contained in:
Lim Chee Aun 2023-01-03 00:52:16 +08:00
parent 72e3d96675
commit dbf9c22ea5

View file

@ -246,27 +246,30 @@ function Home({ hidden }) {
</a> </a>
</div> </div>
</header> </header>
{snapStates.homeNew.length > 0 && ( {snapStates.homeNew.length > 0 &&
<button scrollDirection === 'up' &&
class="updates-button" !nearReachTop &&
type="button" !nearReachBottom && (
onClick={() => { <button
const uniqueHomeNew = snapStates.homeNew.filter( class="updates-button"
(status) => !states.home.some((s) => s.id === status.id), type="button"
); onClick={() => {
states.home.unshift(...uniqueHomeNew); const uniqueHomeNew = snapStates.homeNew.filter(
loadStatuses(true); (status) => !states.home.some((s) => s.id === status.id),
states.homeNew = []; );
states.home.unshift(...uniqueHomeNew);
loadStatuses(true);
states.homeNew = [];
scrollableRef.current?.scrollTo({ scrollableRef.current?.scrollTo({
top: 0, top: 0,
behavior: 'smooth', behavior: 'smooth',
}); });
}} }}
> >
<Icon icon="arrow-up" /> New posts <Icon icon="arrow-up" /> New posts
</button> </button>
)} )}
{snapStates.home.length ? ( {snapStates.home.length ? (
<> <>
<ul class="timeline"> <ul class="timeline">