mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
interface: lazier notifications loading
This commit is contained in:
parent
fa9a7dc0f0
commit
0b7201ac08
@ -149,10 +149,21 @@ export class HarkApi extends BaseApi<StoreState> {
|
||||
});
|
||||
}
|
||||
|
||||
getMore() {
|
||||
const offset = this.store.state.notifications.size;
|
||||
const count = 10;
|
||||
return this.getSubset(offset,count);
|
||||
}
|
||||
|
||||
async getSubset(offset:number, count:number) {
|
||||
const data = await this.scry("hark-store", `/recent/${offset}/${count}`);
|
||||
this.store.handleEvent({ data });
|
||||
}
|
||||
|
||||
async getTimeSubset(start?: Date, end?: Date) {
|
||||
const s = start ? dateToDa(start) : "-";
|
||||
const e = end ? dateToDa(end) : "-";
|
||||
const result = await this.scry("hark-hook", `/time-subset/${s}/${e}`);
|
||||
const result = await this.scry("hark-hook", `/recent/${s}/${e}`);
|
||||
this.store.handleEvent({
|
||||
data: result,
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useCallback } from "react";
|
||||
import f from "lodash/fp";
|
||||
import _ from "lodash";
|
||||
import { Icon, Col, Row, Box, Text, Anchor } from "@tlon/indigo-react";
|
||||
@ -67,8 +67,15 @@ export default function Inbox(props: {
|
||||
f.values
|
||||
)(notifications);
|
||||
|
||||
const onScroll = useCallback((e) => {
|
||||
let container = e.target;
|
||||
if(container.scrollHeight - container.scrollTop === container.clientHeight) {
|
||||
api.hark.getMore();
|
||||
}
|
||||
}, [api]);
|
||||
|
||||
return (
|
||||
<Col overflowY="auto" flexGrow="1">
|
||||
<Col onScroll={onScroll} overflowY="auto" flexGrow="1">
|
||||
{newNotifications && (
|
||||
<DaySection
|
||||
latest
|
||||
|
Loading…
Reference in New Issue
Block a user