Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial PR for reddit wrapper in ReactJS + Typescript #1

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Initial PR for reddit wrapper in ReactJS + Typescript #1

wants to merge 38 commits into from

Conversation

Yarwin
Copy link

@Yarwin Yarwin commented Jun 9, 2017

No description provided.

);
}
if (media.url.indexOf('youtube') !== -1) {
console.log('SPLIT', media.url.split('watch?v='));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

const extension = media.url.split('.')[media.url.split('.').length - 1];
if (media.url.indexOf('gfycat') !== -1) {
return(
<iframe src={`https://thumbs.${media.url.split('://')[1]}-mobile.mp4`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<iframe
     src ...
     scrolling='no'
     width='640'
....
</iframe>

return (<img src={media.url} alt=""/>);
}
if (extension === 'gifv') {
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nasty. Race condition!

const Markdown = require('react-remarkable');


interface IProps {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make proper interfaces, reduce usage of any;

}

public componentDidMount() {
const script = document.createElement('script');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component mound append and on componentWillUnmount should remove that script

@@ -0,0 +1,62 @@
import * as React from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

@@ -0,0 +1,72 @@
import * as React from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

@@ -0,0 +1,39 @@
import * as React from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not used remove it


const mapDispatchToProps = {authorization};

@(connect(null, mapDispatchToProps) as any)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there must be better way

...this.state,
submitted: true,
};
this.setState(newState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be:

this.setState({
...this.state,
submitted: true,
});

dispatch?: any;
isVisible?: boolean;
quanityOfSavedSubreddits?: number;
whereYouAre?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange naming

};

public render() {
const authLink = 'https://www.reddit.com/api/v1/authorize?client_id=YJa94gbugND2ZQ&response_type=code&state=42asdf&redirect_uri=http://localhost:8000/auth&duration=permanent&scope=identity';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be moved into config and set as AUTH_LINK const imported from constants.

<div className="auth-top col-xs-12">
<div className="auth-urself">
<a href={authLink}>
Auth yourself with Leddit account!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - Reddit

public handleChange = (event: any): void => {
const value = event.target.value;
this.setState(
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.setState({...this.state, input:value});

}

interface ISubreddits {
data: Object;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not nice interface

};

private openSubredditOnClick = (subreddit: any ) => {
// return (e: any) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't push commented code

return (
<div className="saved-subreddit-menu-item search-panel-results" key={subreddit.id}>
<Link to={`/${subreddit.display_name_prefixed}/`}>
{/*<span onClick={this.openSubredditOnClick(subreddit)}>*/}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code


const NotFound: StatelessComponent<any> = (): any => {
return (
<div>The page you request is not exist.</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page you requested doesn't exist.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boilerpack default 404 page.


public render() {
const { thread_replies, original_post } = this.props;
console.log('REPLIES', thread_replies);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

src/constants.ts Outdated
@@ -0,0 +1,8 @@
export const TITLES = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or actually have it but remove those constants

@@ -0,0 +1 @@
export const object: any = Object;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line at the end

src/prepare.ts Outdated
const subreddits = require('./reducers/reducer_subreddits_search');
const nextReducer = combineReducers({
routing: routerReducer,
titleReducer,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...reducers as above

@@ -0,0 +1,28 @@
/* Import redcers */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

case FETCH_SUBREDDIT:
return {...state, threads: []};
case FETCH_THREAD:
return {...state,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
    ...state,
    ...
}

@@ -0,0 +1,25 @@
import { GET_NEXT_TITLE, TITLES } from '../constants';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants