Skip to content
Permalink
Browse files

doing less wasteful fetches

  • Loading branch information...
mikekasprzak committed Dec 3, 2016
1 parent 07354d9 commit 18f5a4b77f5752945950278e10ff085f858924db
Binary file not shown.
@@ -1,4 +1,6 @@
import { h, Component } from 'preact/preact';
import ShallowCompare from 'shallow-compare/index';

import NavSpinner from 'com/nav-spinner/spinner';
import NavLink from 'com/nav-link/link';
import SVGIcon from 'com/svg-icon/icon';
@@ -13,18 +15,32 @@ export default class ContentPost extends Component {
author: {}
};

this.componentWillReceiveProps( props );
this.getAuthor( props.node );

this.onLove = this.onLove.bind(this);
this.onMinMax = this.onMinMax.bind(this);
}

// shouldComponentUpdate( nextProps, nextState ) {
// var com = ShallowCompare(this, nextProps, nextState);
//// console.log("HOOP",com,this.props, nextProps);
//// console.log("HOOP",com,this.state, nextState);
// return com;
// }

componentWillReceiveProps( props ) {
// componentWillReceiveProps( props ) {
componentWillUpdate( newProps, newState ) {
if ( this.props.user !== newProps.user ) {
this.getAuthor(newProps.user);
}
}

getAuthor( node ) {
// Clear the Author
this.setState({ author: {} });

// Lookup the author
$Node.Get( props.node.author )
$Node.Get( node.author )
.then(r => {
if ( r.node && r.node.length ) {
this.setState({ author: r.node[0] });
@@ -38,11 +54,6 @@ export default class ContentPost extends Component {
});
}

// componentDidMount() {
// }
// componentWillUnmount() {
// }

onLove( e ) {
console.log("luv");
}
@@ -92,6 +92,7 @@ export default class DialogBase extends Component {

abort() {
window.location.hash = "#";
//location.href = location.pathname+location.search;
}

render( props, {} ) {
@@ -65,7 +65,7 @@ export default class NavBar extends Component {
var GameURL = '/events/ludum-dare/37/theme/';
// TODO: Check if a participant of the current event
MyGame = (
<ButtonLink href={GameURL} class="-button" onclick={e => console.log('my game')}>
<ButtonLink href={GameURL} class="-button">
<SVGIcon>gamepad</SVGIcon>
<div class="if-sidebar-block">Slaughter Themes</div>
</ButtonLink>
@@ -101,7 +101,7 @@ export default class NavBar extends Component {
//'/other/logo/mike/Chicken64.png';
let MyURL = '/users/'+user.slug+'/';
User = (
<ButtonBase class="-user" onclick={e => console.log('user')}>
<ButtonBase class="-user">
<NavLink href={MyURL}>{Avatar}</NavLink>
</ButtonBase>
);
@@ -125,7 +125,7 @@ export default class NavBar extends Component {
<div class="nav-bar">
<div class="-content">
<div class="-left">
<ButtonLink href="/" class="-logo" onclick={e => console.log('logo')}>
<ButtonLink href="/" class="-logo">
<SVGIcon class="if-sidebar-block" baseline>ludum</SVGIcon><SVGIcon class="if-sidebar-block" baseline>dare</SVGIcon>
<SVGIcon class="if-no-sidebar-block" baseline>l-udum</SVGIcon><SVGIcon class="if-no-sidebar-block" baseline>d-are</SVGIcon>
</ButtonLink>
@@ -188,11 +188,9 @@ class Main extends Component {
var slugs = this.cleanLocation(e.detail.location).slugs;

if ( slugs.join() !== this.state.slugs.join() ) {
// console.log('pushState');
history.pushState(null, null, e.detail.location.pathname+e.detail.location.search);

this.setState({ id: 0, slugs: slugs, node: {id: 0} });

this.fetchNode();

// Scroll to top
@@ -211,7 +209,6 @@ class Main extends Component {

componentDidUpdate( prevProps, prevState ) {
var state_copy = Object.assign({},this.state);
// console.log('replaceState', state_copy);
history.replaceState(state_copy, null);
}

0 comments on commit 18f5a4b

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.