Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge pull request #336 from ecency/development
Browse files Browse the repository at this point in the history
fixes to production
  • Loading branch information
feruzm authored Jan 13, 2021
2 parents 690ff1f + e516190 commit 9180638
Show file tree
Hide file tree
Showing 76 changed files with 1,703 additions and 963 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start:prod": "NODE_ENV=production node build/server.js"
},
"dependencies": {
"@ecency/render-helper": "^2.0.13",
"@ecency/render-helper": "^2.0.15",
"@hiveio/dhive": "^0.14.12",
"@hiveio/hivescript": "^1.2.1",
"@types/bs58": "^4.0.1",
Expand All @@ -20,7 +20,7 @@
"@types/pg": "^7.14.4",
"@types/rss": "^0.0.28",
"@types/speakingurl": "^13.0.2",
"axios": "^0.19.2",
"axios": "^0.21.1",
"bootstrap": "^4.5.0",
"bs58": "^4.0.1",
"chartist": "^0.11.4",
Expand Down
56 changes: 56 additions & 0 deletions src/client/base-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Base event handlers for browser window

import {history} from "../common/store";

import routes from "../common/routes";

import {pathToRegexp} from "path-to-regexp";

// Global drag&drop
const handleDragOver = (e: DragEvent) => {
if (!(e.target && e.dataTransfer)) {
Expand All @@ -11,6 +17,56 @@ const handleDragOver = (e: DragEvent) => {
e.dataTransfer.dropEffect = 'none';
}

// Global click handler
const handleClick = (e: Event) => {
const el = e.target as HTMLElement;

// Anchor link handler
if (el.tagName === "A") {
const href = el.getAttribute("href");
if (href && href.startsWith("/") && href.indexOf("#") !== -1) {
const [route, anchor] = href.split("#");

// make sure link matches with one of app routes
if (Object.values(routes).find(p => pathToRegexp(p).test(route))) {
e.preventDefault();

let delay = 100;

if (history!.location.pathname !== route) {
history!.push(href);
delay = 400;
}

// scroll to anchor element
const el = document.getElementById(anchor);
if (el) {
setTimeout(() => {
el.scrollIntoView();
}, delay);
}
}
}
}

// Handle links in static pages. (faq etc...)
if (el.tagName === "A") {
if (el.classList.contains("push-link")) {
e.preventDefault();
const href = el.getAttribute("href");
if (href && href.startsWith("/")) {

// make sure link matches with one of app routes
if (Object.values(routes).find(p => pathToRegexp(p).test(href))) {
e.preventDefault();
history!.push(href);
}
}
}
}
}

document.addEventListener("DOMContentLoaded", function () {
document.body.addEventListener('dragover', handleDragOver);
document.body.addEventListener('click', handleClick);
});
8 changes: 7 additions & 1 deletion src/common/api/hive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,11 @@ export const downVotingPower = (account: FullAccount): number => {

const pow = downVotePerc * 100 + (10000 * secondsDiff / 432000);

return Math.min(pow / 100, 100);
const rv = Math.min(pow / 100, 100);

if (isNaN(rv)) {
return 0;
}

return rv;
};
2 changes: 1 addition & 1 deletion src/common/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const App = () => {
<Route exact={true} strict={true} path={routes.TOS} component={TosPageContainer}/>
<Route exact={true} strict={true} path={routes.FAQ} component={FaqPageContainer}/>
<Route exact={true} strict={true} path={routes.CONTRIBUTORS} component={ContributorsPageContainer}/>
<Route component={() => <NotFound/>}/>
<Route component={NotFound}/>
</Switch>
</>
);
Expand Down
78 changes: 56 additions & 22 deletions src/common/components/404/index.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,64 @@
import React, { Component } from "react";
import React, {Component} from "react";

import {History} from "history";

import {Link} from "react-router-dom";

import { Link } from "react-router-dom";
import Meta from "../meta";

const logoCircle = require("../../img/logo-circle.svg");

export default class NotFound extends Component {
render() {
const metaProps = {
title: "404",
interface Props {
history: History;
}

export class NotFound extends Component<Props> {
goBack = () => {
const {history} = this.props;

history.goBack();
};

return (
<>
<Meta {...metaProps} />
<div className="not-found-404">
<img src={logoCircle} className="logo" />
<h1>This page doesn't exist.</h1>
<p className="links">
<Link to="/">Home</Link>
<Link to="/created">New posts</Link>
<Link to="/hot">Hot posts</Link>
<Link to="/trending">Trending posts</Link>
</p>
</div>
</>
);
}
render() {
const metaProps = {
title: "404",
};

const {history} = this.props;

// @ts-ignore make ide happy. code compiles without error.
const entries = history.entries || {}
// @ts-ignore
const index = history.index || 0;

const canGoBack = !!entries[index - 1];

return (
<>
<Meta {...metaProps} />
<div className="not-found-404">
<img src={logoCircle} className="logo" alt="Ecency"/>
<h1>This page doesn't exist.</h1>
<p className="links">
{canGoBack && <a href="#" onClick={(e) => {
e.preventDefault();
this.goBack();
}}>Back</a>}
<Link to="/">Home</Link>
<Link to="/created">New posts</Link>
<Link to="/hot">Hot posts</Link>
<Link to="/trending">Trending posts</Link>
</p>
</div>
</>
);
}
}

export default (p: Props) => {
const props = {
history: p.history
}

return <NotFound {...props}/>
}
2 changes: 1 addition & 1 deletion src/common/components/delegated-vesting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class List extends Component<Props, State> {
.finally(() => this.stateSet({inProgress: false}))
},
onHot: () => {
delegateVestingSharesHot(activeUser.username, username, "0.000000");
delegateVestingSharesHot(activeUser.username, username, "0.000000 VESTS");
},
onKc: () => {
this.stateSet({inProgress: true});
Expand Down
Loading

0 comments on commit 9180638

Please sign in to comment.