Skip to content

Commit

Permalink
feat: add history lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
sentialx committed Sep 23, 2019
1 parent 700160d commit e13d94e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"react-windows-controls": "1.1.1",
"styled-components": "^5.0.0-beta.8",
"tldts-experimental": "5.4.1",
"ts-loader": "^6.1.0",
"ts-loader": "^6.1.2",
"typescript": "3.6.3",
"v8-compile-cache": "^2.1.0",
"webpack": "4.40.2",
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/views/history/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import { Container, Content, LeftContent } from '~/renderer/components/Pages';

const GlobalStyle = createGlobalStyle`${Style}`;

const onScroll = (e: any) => {
const scrollPos = e.target.scrollTop;
const scrollMax = e.target.scrollHeight - e.target.clientHeight - 256;

if (scrollPos >= scrollMax) {
store.itemsLoaded += store.getDefaultLoaded();
}
};

const RangeItem = observer(
({ range, children }: { range: QuickRange; children: any }) => (
<NavigationDrawer.Item
Expand Down Expand Up @@ -77,7 +86,7 @@ export default observer(() => {
Clear browsing data
</NavigationDrawer.Item>
</NavigationDrawer>
<Content>
<Content onScroll={onScroll}>
<HistorySections />
</Content>
</Container>
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/views/menu/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Store {
public settings: ISettings = DEFAULT_SETTINGS;

@observable
public visible = true;
public visible = false;

@observable
public id = remote.getCurrentWebContents().id;
Expand All @@ -22,10 +22,6 @@ export class Store {
this.visible = flag;
});

setTimeout(() => {
this.visible = false;
});

window.addEventListener('blur', () => {
if (this.visible) {
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/settings/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default observer(() => {
{/* <MenuItem section="system">System</MenuItem> */}
</NavigationDrawer>
<Content>
<LeftContent>
<LeftContent style={{ maxWidth: 800 }}>
{selectedSection === 'appearance' && <Appearance />}
{selectedSection === 'autofill' && <Autofill />}
{selectedSection === 'address-bar' && <AddressBar />}
Expand Down

0 comments on commit e13d94e

Please sign in to comment.